本文整理汇总了Python中geotrek.maintenance.factories.ProjectFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Python ProjectFactory.create方法的具体用法?Python ProjectFactory.create怎么用?Python ProjectFactory.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类geotrek.maintenance.factories.ProjectFactory
的用法示例。
在下文中一共展示了ProjectFactory.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_project_bbox_filter
# 需要导入模块: from geotrek.maintenance.factories import ProjectFactory [as 别名]
# 或者: from geotrek.maintenance.factories.ProjectFactory import create [as 别名]
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)
示例2: test_form_deleted_projects
# 需要导入模块: from geotrek.maintenance.factories import ProjectFactory [as 别名]
# 或者: from geotrek.maintenance.factories.ProjectFactory import create [as 别名]
def test_form_deleted_projects(self):
self.login()
p1 = ProjectFactory.create()
p2 = ProjectFactory.create()
i = InterventionFactory.create(project=p1)
response = self.client.get(i.get_update_url())
self.assertEqual(response.status_code, 200)
form = self.get_form(response)
projects = form.fields['project'].queryset.all()
self.assertItemsEqual(projects, [p1, p2])
p2.delete()
projects = form.fields['project'].queryset.all()
self.assertItemsEqual(projects, [p1])
示例3: test_project_layer
# 需要导入模块: from geotrek.maintenance.factories import ProjectFactory [as 别名]
# 或者: from geotrek.maintenance.factories.ProjectFactory import create [as 别名]
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)
示例4: setUp
# 需要导入模块: from geotrek.maintenance.factories import ProjectFactory [as 别名]
# 或者: from geotrek.maintenance.factories.ProjectFactory import create [as 别名]
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)
示例5: test_helpers
# 需要导入模块: from geotrek.maintenance.factories import ProjectFactory [as 别名]
# 或者: from geotrek.maintenance.factories.ProjectFactory import create [as 别名]
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)
示例6: test_path_helpers
# 需要导入模块: from geotrek.maintenance.factories import ProjectFactory [as 别名]
# 或者: from geotrek.maintenance.factories.ProjectFactory import create [as 别名]
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])
示例7: create_pair_of_distinct_by_topo_project
# 需要导入模块: from geotrek.maintenance.factories import ProjectFactory [as 别名]
# 或者: from geotrek.maintenance.factories.ProjectFactory import create [as 别名]
def create_pair_of_distinct_by_topo_project(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)
it_p1 = InterventionFactory.create(topology=topo_1)
seek_it = InterventionFactory.create(topology=seek_topo)
seek_proj = ProjectFactory.create()
seek_proj.interventions.add(seek_it)
proj_1 = ProjectFactory.create()
proj_1.interventions.add(it_p1)
return seek_proj, seek_path
示例8: test_deleted_intervention
# 需要导入模块: from geotrek.maintenance.factories import ProjectFactory [as 别名]
# 或者: from geotrek.maintenance.factories.ProjectFactory import create [as 别名]
def test_deleted_intervention(self):
i1 = InterventionFactory.create()
sign = SignageFactory.create()
i1.set_topology(sign)
i1.save()
proj = ProjectFactory.create()
proj.interventions.add(i1)
self.assertEquals(proj.signages, [sign])
i1.delete()
self.assertEquals(proj.signages, [])
示例9: test_deleted_infrastructure
# 需要导入模块: from geotrek.maintenance.factories import ProjectFactory [as 别名]
# 或者: from geotrek.maintenance.factories.ProjectFactory import create [as 别名]
def test_deleted_infrastructure(self):
i1 = InterventionFactory.create()
infra = InfrastructureFactory.create()
i1.set_infrastructure(infra)
proj = ProjectFactory.create()
proj.interventions.add(i1)
self.assertEquals(proj.infrastructures, [infra])
infra.delete()
self.assertEquals(proj.infrastructures, [])
示例10: test_deleted_interventions
# 需要导入模块: from geotrek.maintenance.factories import ProjectFactory [as 别名]
# 或者: from geotrek.maintenance.factories.ProjectFactory import create [as 别名]
def test_deleted_interventions(self):
project = ProjectFactory.create()
intervention = InterventionFactory.create()
project.interventions.add(intervention)
response = self.client.get(project.get_detail_url())
self.assertEqual(response.status_code, 200)
self.assertContains(response, intervention.name)
intervention.delete()
response = self.client.get(project.get_detail_url())
self.assertEqual(response.status_code, 200)
self.assertNotContains(response, intervention.name)
示例11: test_project_bbox_filter
# 需要导入模块: from geotrek.maintenance.factories import ProjectFactory [as 别名]
# 或者: from geotrek.maintenance.factories.ProjectFactory import create [as 别名]
def test_project_bbox_filter(self):
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((-1.3630753338765911%20-5.9838497371070440%2C%20-1.3630694576343052%20-5.9838497371070440%2C%20-1.3630694576343052%20-5.9838431650051289%2C%20-1.3630753338765911%20-5.9838431650051289%2C%20-1.3630753338765911%20-5.9838497371070440))'
self.assertEqual(len(jsonlist(bbox)), 3)
示例12: test_helpers
# 需要导入模块: from geotrek.maintenance.factories import ProjectFactory [as 别名]
# 或者: from geotrek.maintenance.factories.ProjectFactory import create [as 别名]
def test_helpers(self):
i1 = InterventionFactory.create()
i2 = InterventionFactory.create()
i3 = InterventionFactory.create()
sign = SignageFactory.create()
i1.set_topology(sign)
p1 = sign.paths.get()
infra = InfrastructureFactory.create()
i2.set_topology(infra)
p2 = infra.paths.get()
t = TopologyFactory.create(no_path=True)
PathAggregationFactory.create(topo_object=t, path=p1)
i3.topology = t
proj = ProjectFactory.create()
self.assertItemsEqual(proj.paths.all(), [])
self.assertEquals(proj.signages, [])
self.assertEquals(proj.infrastructures, [])
i1.save()
proj.interventions.add(i1)
self.assertItemsEqual(proj.paths.all(), [p1])
self.assertEquals(proj.signages, [sign])
self.assertEquals(proj.infrastructures, [])
i2.save()
proj.interventions.add(i2)
self.assertItemsEqual(proj.paths.all(), [p1, p2])
self.assertEquals(proj.signages, [sign])
self.assertEquals(proj.infrastructures, [infra])
i3.save()
proj.interventions.add(i3)
self.assertItemsEqual(proj.paths.all(), [p1, p2])
self.assertEquals(proj.signages, [sign])
self.assertEquals(proj.infrastructures, [infra])
示例13: test_new_projects_can_be_filtered_on_new_years
# 需要导入模块: from geotrek.maintenance.factories import ProjectFactory [as 别名]
# 或者: from geotrek.maintenance.factories.ProjectFactory import create [as 别名]
def test_new_projects_can_be_filtered_on_new_years(self):
filter = ProjectFilterSet(data={'in_year': 1250})
p = ProjectFactory.create(begin_year=1200, end_year=1300)
self.assertIn(p, filter.qs)
self.assertEqual(len(filter.qs), 1)
示例14: test_filter_year_with_string
# 需要导入模块: from geotrek.maintenance.factories import ProjectFactory [as 别名]
# 或者: from geotrek.maintenance.factories.ProjectFactory import create [as 别名]
def test_filter_year_with_string(self):
filter = ProjectFilterSet(data={'in_year': 'toto'})
p = ProjectFactory.create(begin_year=1200, end_year=1300)
self.assertIn(p, filter.qs)
self.assertEqual(len(filter.qs), 3)
示例15: test_new_interventions_appear_dynamically
# 需要导入模块: from geotrek.maintenance.factories import ProjectFactory [as 别名]
# 或者: from geotrek.maintenance.factories.ProjectFactory import create [as 别名]
def test_new_interventions_appear_dynamically(self):
ProjectFactory.create(begin_year=1500, end_year=2100)
output = self.widget.render(name='year', value=None)
self.assertEqual(output.count('<option'), 6)
self.assertIn('>2100<', output)