本文整理汇总了Python中geotrek.maintenance.factories.InterventionFactory类的典型用法代码示例。如果您正苦于以下问题:Python InterventionFactory类的具体用法?Python InterventionFactory怎么用?Python InterventionFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InterventionFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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)
示例2: test_project_bbox_filter
def test_project_bbox_filter(self):
self.login()
p1 = ProjectFactory.create()
ProjectFactory.create()
ProjectFactory.create()
t = TopologyFactory.create()
InterventionFactory.create(project=p1, topology=t)
def jsonlist(bbox):
url = self.model.get_jsonlist_url() + bbox
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
jsondict = json.loads(response.content)
return jsondict['aaData']
# Check that projects without interventions are always present
self.assertEqual(len(Project.objects.all()), 3)
self.assertEqual(len(jsonlist('')), 3)
self.assertEqual(len(jsonlist('?bbox=POLYGON((1%202%200%2C1%202%200%2C1%202%200%2C1%202%200%2C1%202%200))')), 2)
# Give a bbox that match intervention, and check that all 3 projects are back
bbox = '?bbox=POLYGON((2.9%2046.4%2C%203.1%2046.4%2C%203.1%2046.6%2C%202.9%2046.6%2C%202.9%2046.4))'
self.assertEqual(len(jsonlist(bbox)), 3)
示例3: 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])
示例4: 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)
示例5: 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)
示例6: create_pair_of_distinct_by_topo_intervention
def create_pair_of_distinct_by_topo_intervention(self):
p1, seek_path = self.create_pair_of_distinct_path()
topo_1 = TopologyFactory.create(no_path=True)
PathAggregationFactory.create(topo_object=topo_1, path=p1, start_position=0, end_position=1)
seek_topo = TopologyFactory.create(no_path=True)
PathAggregationFactory.create(topo_object=seek_topo, path=seek_path, start_position=0, end_position=1)
it_p1 = InterventionFactory.create(topology=topo_1)
seek_it = InterventionFactory.create(topology=seek_topo)
return seek_it, seek_path
示例7: create_pair_of_distinct_by_topo_intervention
def create_pair_of_distinct_by_topo_intervention(self):
p1, seek_path = self.create_pair_of_distinct_path()
topo_1 = TopologyFactory.create(no_path=True)
topo_1.add_path(path=p1, start=0, end=1)
seek_topo = TopologyFactory.create(no_path=True)
seek_topo.add_path(path=seek_path, start=0, end=1)
InterventionFactory.create(topology=topo_1)
seek_it = InterventionFactory.create(topology=seek_topo)
return seek_it, seek_path
示例8: test_project_layer
def test_project_layer(self):
p1 = ProjectFactory.create()
ProjectFactory.create()
InterventionFactory.create(project=p1)
# Check that only p1 is in geojson
response = self.client.get(self.model.get_layer_url())
self.assertEqual(response.status_code, 200)
geojson = json.loads(response.content)
features = geojson['features']
self.assertEqual(len(Project.objects.all()), 2)
self.assertEqual(len(features), 1)
self.assertEqual(features[0]['properties']['pk'], p1.pk)
示例9: 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)
示例10: 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)
示例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_update_form_on_signage
def test_update_form_on_signage(self):
self.login()
signa = SignageFactory.create()
signage = u"%s" % signa
intervention = InterventionFactory.create()
self.assertIsNone(intervention.signage)
intervention.set_topology(signa)
intervention.save()
self.assertIsNotNone(intervention.signage)
response = self.client.get(intervention.get_update_url())
self.assertEqual(response.status_code, 200)
self.assertContains(response, signage)
# Should be able to save form successfully
form = response.context['form']
data = form.initial
data['disorders'] = data['disorders'][0].pk
data['project'] = ''
data['signage'] = form.fields['signage'].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() + '?signage=%s' % signa.pk
response = self.client.post(formurl, data)
self.assertEqual(response.status_code, 302)
示例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_structurerelated_not_loggedin
def test_structurerelated_not_loggedin(self):
# Test that it does not fail on update if not logged in
self.client.logout()
response = self.client.get(Intervention.get_add_url())
self.assertEqual(response.status_code, 302)
i = InterventionFactory.create()
response = self.client.get(i.get_update_url())
self.assertEqual(response.status_code, 302)