本文整理匯總了Python中geotrek.infrastructure.factories.InfrastructureFactory類的典型用法代碼示例。如果您正苦於以下問題:Python InfrastructureFactory類的具體用法?Python InfrastructureFactory怎麽用?Python InfrastructureFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了InfrastructureFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_none_implantation_year_filter
def test_none_implantation_year_filter(self):
self.login()
model = self.factory._meta.model
InfrastructureFactory.create()
response = self.client.get(model.get_list_url())
self.assertFalse('option value="" selected>None</option' in str(response))
示例2: create_trek_with_infrastructures
def create_trek_with_infrastructures(obj, create, extracted, **kwargs):
path = obj.paths.all()[0]
infra1 = InfrastructureFactory.create(no_path=True)
infra1.add_path(path, start=0.5, end=0.5)
infra2 = InfrastructureFactory.create(no_path=True)
infra2.add_path(path, start=0.4, end=0.4)
if create:
obj.save()
示例3: test_implantation_year_filter_with_str
def test_implantation_year_filter_with_str(self):
filter = InfrastructureFilterSet(data={'implantation_year': 'toto'})
self.login()
model = self.factory._meta.model
i = InfrastructureFactory.create(implantation_year=2015)
i2 = InfrastructureFactory.create(implantation_year=2016)
response = self.client.get(model.get_list_url())
self.assertTrue('<option value="2015">2015</option>' in str(response))
self.assertTrue('<option value="2016">2016</option>' in str(response))
self.assertIn(i, filter.qs)
self.assertIn(i2, filter.qs)
示例4: test_path_helpers
def test_path_helpers(self):
p = PathFactory.create()
self.assertEquals(len(p.interventions), 0)
self.assertEquals(len(p.projects), 0)
sign = SignageFactory.create(no_path=True)
sign.add_path(p, start=0.5, end=0.5)
infra = InfrastructureFactory.create(no_path=True)
infra.add_path(p)
i1 = InterventionFactory.create()
i1.set_infrastructure(sign)
i1.save()
self.assertItemsEqual(p.interventions, [i1])
i2 = InterventionFactory.create()
i2.set_infrastructure(infra)
i2.save()
self.assertItemsEqual(p.interventions, [i1, i2])
proj = ProjectFactory.create()
proj.interventions.add(i1)
proj.interventions.add(i2)
self.assertItemsEqual(p.projects, [proj])
示例5: setUp
def setUp(self):
self.intervention = InterventionFactory.create()
self.project = ProjectFactory.create()
self.project.interventions.add(self.intervention)
self.project.interventions.add(InterventionFactory.create())
infra = InfrastructureFactory.create()
self.intervention.set_infrastructure(infra)
self.intervention.save()
path = infra.paths.get()
self.signagemgt = SignageManagementEdgeFactory.create(no_path=True)
self.signagemgt.add_path(path, start=0.3, end=0.7)
self.workmgt = WorkManagementEdgeFactory.create(no_path=True)
self.workmgt.add_path(path, start=0.3, end=0.7)
self.competencemgt = CompetenceEdgeFactory.create(no_path=True)
self.competencemgt.add_path(path, start=0.3, end=0.7)
self.cityedge = CityEdgeFactory.create(no_path=True)
self.cityedge.add_path(path, start=0.3, end=0.7)
self.districtedge = DistrictEdgeFactory.create(no_path=True)
self.districtedge.add_path(path, start=0.3, end=0.7)
self.restricted = RestrictedAreaEdgeFactory.create(no_path=True)
self.restricted.add_path(path, start=0.3, end=0.7)
示例6: test_delete_show_topologies
def test_delete_show_topologies(self):
self.login()
path = PathFactory(name="PATH_AB", geom=LineString((0, 0), (4, 0)))
poi = POIFactory.create(name='POI', no_path=True)
poi.add_path(path, start=0.5, end=0.5)
trail = TrailFactory.create(name='Trail', no_path=True)
trail.add_path(path, start=0.1, end=0.2)
trek = TrekFactory.create(name='Trek', no_path=True)
trek.add_path(path, start=0.2, end=0.3)
service = ServiceFactory.create(no_path=True, type__name='ServiceType')
service.add_path(path, start=0.2, end=0.3)
signage = SignageFactory.create(name='Signage', no_path=True)
signage.add_path(path, start=0.2, end=0.2)
infrastructure = InfrastructureFactory.create(name='Infrastructure', no_path=True)
infrastructure.add_path(path, start=0.2, end=0.2)
intervention1 = InterventionFactory.create(topology=signage, name='Intervention1')
t = TopologyFactory.create(no_path=True)
t.add_path(path, start=0.2, end=0.5)
intervention2 = InterventionFactory.create(topology=t, name='Intervention2')
response = self.client.get(path.get_delete_url())
self.assertEqual(response.status_code, 200)
self.assertContains(response, 'Different topologies are linked with this path')
self.assertContains(response, '<a href="/poi/%d/">POI</a>' % poi.pk)
self.assertContains(response, '<a href="/trail/%d/">Trail</a>' % trail.pk)
self.assertContains(response, '<a href="/trek/%d/">Trek</a>' % trek.pk)
self.assertContains(response, '<a href="/service/%d/">ServiceType</a>' % service.pk)
self.assertContains(response, '<a href="/signage/%d/">Signage</a>' % signage.pk)
self.assertContains(response, '<a href="/infrastructure/%d/">Infrastructure</a>' % infrastructure.pk)
self.assertContains(response, '<a href="/intervention/%d/">Intervention1</a>' % intervention1.pk)
self.assertContains(response, '<a href="/intervention/%d/">Intervention2</a>' % intervention2.pk)
示例7: test_update_form_on_infrastructure
def test_update_form_on_infrastructure(self):
self.login()
infra = InfrastructureFactory.create()
infrastr = u"%s" % infra
intervention = InterventionFactory.create()
intervention.set_infrastructure(infra)
intervention.save()
response = self.client.get(intervention.get_update_url())
self.assertEqual(response.status_code, 200)
self.assertContains(response, infrastr)
# Should be able to save form successfully
form = response.context['form']
data = form.initial
data['project'] = ''
data['infrastructure'] = form.fields['infrastructure'].initial.pk # because it is set after form init, not form.initial :(
data.update(**{
'manday_set-TOTAL_FORMS': '0',
'manday_set-INITIAL_FORMS': '0',
'manday_set-MAX_NUM_FORMS': '',
})
# Form URL is modified in form init
formurl = intervention.get_update_url() + '?infrastructure=%s' % infra.pk
response = self.client.post(formurl, data)
self.assertEqual(response.status_code, 302)
示例8: test_helpers
def test_helpers(self):
p = PathFactory.create()
infra = InfrastructureFactory.create(no_path=True)
infra.add_path(path=p)
self.assertItemsEqual(p.infrastructures, [infra])
示例9: _prepare
def _prepare(cls, create, **kwargs):
intervention = super(InfrastructureInterventionFactory, cls)._prepare(create, **kwargs)
infra = InfrastructureFactory.create()
intervention.set_infrastructure(infra)
if create:
intervention.save()
return intervention
示例10: test_delete_multiple_path
def test_delete_multiple_path(self):
path_1 = PathFactory.create(name="path_1", geom=LineString((0, 0), (4, 0)))
path_2 = PathFactory.create(name="path_2", geom=LineString((2, 2), (2, -2)))
poi = POIFactory.create(no_path=True, name="POI_1")
poi.add_path(path_1, start=0, end=0)
infrastructure = InfrastructureFactory.create(no_path=True, name="INFRA_1")
infrastructure.add_path(path_1, start=0, end=1)
signage = SignageFactory.create(no_path=True, name="SIGNA_1")
signage.add_path(path_1, start=0, end=1)
trail = TrailFactory.create(no_path=True, name="TRAIL_1")
trail.add_path(path_2, start=0, end=1)
service = ServiceFactory.create(no_path=True)
service.add_path(path_2, start=0, end=1)
InterventionFactory.create(topology=signage, name="INTER_1")
response = self.client.get(reverse('core:multiple_path_delete', args=['%s,%s' % (path_1.pk, path_2.pk)]))
self.assertIn("POI_1", response.content)
self.assertIn("INFRA_1", response.content)
self.assertIn("SIGNA_1", response.content)
self.assertIn("TRAIL_1", response.content)
self.assertIn("ServiceType", response.content)
self.assertIn("INTER_1", response.content)
response = self.client.post(reverse('core:multiple_path_delete', args=['%s,%s' % (path_1.pk, path_2.pk)]))
self.assertEqual(response.status_code, 302)
self.assertEqual(Path.objects.count(), 2)
self.assertEqual(Path.objects.filter(pk__in=[path_1.pk, path_2.pk]).count(), 0)
示例11: test_helpers
def test_helpers(self):
infra = InfrastructureFactory.create()
sign = SignageFactory.create()
interv = InterventionFactory.create()
proj = ProjectFactory.create()
self.assertFalse(interv.on_infrastructure)
self.assertEquals(interv.infrastructure, None)
interv.set_infrastructure(infra)
self.assertTrue(interv.on_infrastructure)
self.assertFalse(interv.is_signage)
self.assertTrue(interv.is_infrastructure)
self.assertEquals(interv.signages, [])
self.assertEquals(interv.infrastructures, [infra])
self.assertEquals(interv.infrastructure, infra)
interv.set_infrastructure(sign)
self.assertTrue(interv.on_infrastructure)
self.assertTrue(interv.is_signage)
self.assertFalse(interv.is_infrastructure)
self.assertEquals(interv.signages, [sign])
self.assertEquals(interv.infrastructures, [])
self.assertEquals(interv.infrastructure, sign)
self.assertFalse(interv.in_project)
interv.project = proj
self.assertTrue(interv.in_project)
示例12: test_default_stake
def test_default_stake(self):
i = InterventionFactory.create()
i.stake = None
self.assertTrue(i.stake is None)
i.save()
self.assertTrue(i.stake is None)
lowstake = StakeFactory.create()
highstake = StakeFactory.create()
if lowstake > highstake:
tmp = lowstake
lowstake = highstake
highstake = tmp
# Add paths to topology
infra = InfrastructureFactory.create(no_path=True)
infra.add_path(PathFactory.create(stake=lowstake))
infra.add_path(PathFactory.create(stake=highstake))
infra.add_path(PathFactory.create(stake=lowstake))
i.set_infrastructure(infra)
# Stake is not None anymore
i.save()
self.assertFalse(i.stake is None)
# Make sure it took higher stake
self.assertEqual(i.stake, highstake)
示例13: test_delete_topology
def test_delete_topology(self):
infra = InfrastructureFactory.create()
interv = InterventionFactory.create()
interv.set_infrastructure(infra)
interv.save()
infra.delete()
self.assertEqual(Infrastructure.objects.existing().count(), 0)
self.assertEqual(Intervention.objects.existing().count(), 0)
示例14: test_infrastructure
def test_infrastructure(self):
i = InterventionFactory.create()
self.assertFalse(i.on_existing_topology)
infra = InfrastructureFactory.create()
i.set_topology(infra)
self.assertTrue(i.on_existing_topology)
sign = SignageFactory.create()
i.set_topology(sign)
self.assertTrue(i.on_existing_topology)
示例15: test_infrastructure
def test_infrastructure(self):
i = InterventionFactory.create()
self.assertFalse(i.on_infrastructure)
infra = InfrastructureFactory.create()
i.set_infrastructure(infra)
self.assertTrue(i.on_infrastructure)
sign = SignageFactory.create()
i.set_infrastructure(sign)
self.assertTrue(i.on_infrastructure)