当前位置: 首页>>代码示例>>Python>>正文


Python factories.ProjectFactory类代码示例

本文整理汇总了Python中geotrek.maintenance.factories.ProjectFactory的典型用法代码示例。如果您正苦于以下问题:Python ProjectFactory类的具体用法?Python ProjectFactory怎么用?Python ProjectFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ProjectFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: 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)
开发者ID:makinacorpus,项目名称:Geotrek,代码行数:25,代码来源:test_views.py

示例2: test_form_deleted_projects

 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])
开发者ID:leplatrem,项目名称:Geotrek,代码行数:13,代码来源:tests.py

示例3: 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)
开发者ID:leplatrem,项目名称:Geotrek,代码行数:14,代码来源:tests.py

示例4: 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)
开发者ID:Pitchs,项目名称:Geotrek,代码行数:25,代码来源:test_project.py

示例5: 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)
开发者ID:Web5design,项目名称:Geotrek,代码行数:28,代码来源:intervention.py

示例6: 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])
开发者ID:Web5design,项目名称:Geotrek,代码行数:29,代码来源:intervention.py

示例7: create_pair_of_distinct_by_topo_project

    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
开发者ID:makinacorpus,项目名称:Geotrek,代码行数:19,代码来源:test_filters.py

示例8: test_deleted_intervention

    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, [])
开发者ID:makinacorpus,项目名称:Geotrek,代码行数:11,代码来源:test_project.py

示例9: test_deleted_infrastructure

    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, [])
开发者ID:Web5design,项目名称:Geotrek,代码行数:12,代码来源:project.py

示例10: test_deleted_interventions

    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)
开发者ID:leplatrem,项目名称:Geotrek,代码行数:14,代码来源:tests.py

示例11: test_project_bbox_filter

    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)
开发者ID:leplatrem,项目名称:Geotrek,代码行数:23,代码来源:tests.py

示例12: test_helpers

    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])
开发者ID:makinacorpus,项目名称:Geotrek,代码行数:41,代码来源:test_project.py

示例13: test_new_projects_can_be_filtered_on_new_years

 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)
开发者ID:makinacorpus,项目名称:Geotrek,代码行数:5,代码来源:test_filters.py

示例14: test_filter_year_with_string

 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)
开发者ID:makinacorpus,项目名称:Geotrek,代码行数:5,代码来源:test_filters.py

示例15: test_new_interventions_appear_dynamically

 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)
开发者ID:adrianmo,项目名称:Geotrek,代码行数:5,代码来源:test_filters.py


注:本文中的geotrek.maintenance.factories.ProjectFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。