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


Python factories.TrekFactory类代码示例

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


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

示例1: test_trek_child_as_parent

 def test_trek_child_as_parent(self):
     a = TrekFactory.create(name='A')
     b = TrekFactory.create(name='B', parent=a)
     c = TrekFactory.create(name='C', parent=b)
     self.assertRaisesMessage(ValidationError,
                              u"Cannot use a a child trek as parent trek.",
                              c.full_clean)
开发者ID:Babawah,项目名称:Geotrek,代码行数:7,代码来源:test_models.py

示例2: test_gpx

 def test_gpx(self):
     trek = TrekFactory.create()
     trek = TrekFactory.create()
     url = reverse('trekking:trek_gpx_detail', kwargs={'pk': trek.pk})
     response = self.client.get(url)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.content.count('<rte>'), 1)
     self.assertTrue(response.content.count('<rtept') >= 2)
开发者ID:leplatrem,项目名称:Geotrek,代码行数:8,代码来源:tests.py

示例3: setUp

 def setUp(self):
     profile = UserProfileFactory.create(user__username='homer',
                                         user__password='dooh',
                                         language='en')
     self.user = profile.user
     self.user.groups.add(Group.objects.get(name=u"Référents communication"))
     self.client.login(username='homer', password='dooh')
     self.content1 = TrekFactory.create()
     structure = StructureFactory.create()
     self.content2 = TrekFactory.create(structure=structure)
开发者ID:Babawah,项目名称:Geotrek,代码行数:10,代码来源:test_views.py

示例4: get_good_data

    def get_good_data(self):
        path = PathFactory.create()
        return {
            'name_fr': 'Huhu',
            'name_en': 'Hehe',
            'departure_fr': '',
            'departure_en': '',
            'arrival_fr': '',
            'arrival_en': '',
            'published': '',
            'difficulty': '',
            'route': '',
            'description_teaser_fr': '',
            'description_teaser_en': '',
            'description_fr': '',
            'description_en': '',
            'ambiance_fr': '',
            'ambiance_en': '',
            'access_fr': '',
            'access_en': '',
            'disabled_infrastructure_fr': '',
            'disabled_infrastructure_en': '',
            'duration': '0',
            'is_park_centered': '',
            'advised_parking': 'Very close',
            'parking_location': 'POINT (1.0 1.0)',
            'public_transport': 'huhu',
            'advice_fr': '',
            'advice_en': '',
            'themes': ThemeFactory.create().pk,
            'networks': TrekNetworkFactory.create().pk,
            'practice': '',
            'accessibilities': AccessibilityFactory.create().pk,
            'web_links': WebLinkFactory.create().pk,
            'information_desks': tourism_factories.InformationDeskFactory.create().pk,
            'topology': '{"paths": [%s]}' % path.pk,

            'trek_relationship_a-TOTAL_FORMS': '2',
            'trek_relationship_a-INITIAL_FORMS': '0',
            'trek_relationship_a-MAX_NUM_FORMS': '',

            'trek_relationship_a-0-id': '',
            'trek_relationship_a-0-trek_b': TrekFactory.create().pk,
            'trek_relationship_a-0-has_common_edge': 'on',
            'trek_relationship_a-0-has_common_departure': 'on',
            'trek_relationship_a-0-is_circuit_step': '',

            'trek_relationship_a-1-id': '',
            'trek_relationship_a-1-trek_b': TrekFactory.create().pk,
            'trek_relationship_a-1-has_common_edge': '',
            'trek_relationship_a-1-has_common_departure': '',
            'trek_relationship_a-1-is_circuit_step': 'on',
        }
开发者ID:Babawah,项目名称:Geotrek,代码行数:53,代码来源:test_views.py

示例5: test_treks_are_sorted_by_name

 def test_treks_are_sorted_by_name(self):
     TrekFactory.create(name='Cb')
     TrekFactory.create(name='Ca')
     TrekFactory.create(name='A')
     TrekFactory.create(name='B')
     self.assertEqual([u'A', u'B', u'Ca', u'Cb'],
                      list(Trek.objects.all().values_list('name', flat=True)))
开发者ID:Babawah,项目名称:Geotrek,代码行数:7,代码来源:test_models.py

示例6: test_treks_are_sorted_by_name

 def test_treks_are_sorted_by_name(self):
     TrekFactory.create(name='Cb')
     TrekFactory.create(name='Ca')
     TrekFactory.create(name='A')
     TrekFactory.create(name='B')
     self.assertQuerysetEqual(Trek.objects.all(),
                              [u'<Trek: A>', u'<Trek: B>', u'<Trek: Ca>', u'<Trek: Cb>'],
                              ordered=False)
开发者ID:makinacorpus,项目名称:Geotrek,代码行数:8,代码来源:test_models.py

示例7: test_json_detail

    def test_json_detail(self):
        trek = TrekFactory.create()
        self.information_desk = InformationDeskFactory.create()
        trek.information_desks.add(self.information_desk)

        url = reverse('trekking:trek_json_detail', kwargs={'pk': trek.pk})
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        detailjson = json.loads(response.content)
        self.assertDictEqual(detailjson['route'],
                             {"id": trek.route.id,
                              "pictogram": None,
                              "label": trek.route.route})
        self.assertDictEqual(detailjson['difficulty'],
                             {"id": trek.difficulty.id,
                              "pictogram": os.path.join(settings.MEDIA_URL, trek.difficulty.pictogram.name),
                              "label": trek.difficulty.difficulty})
        self.assertDictEqual(detailjson['information_desk'],
                             detailjson['information_desks'][0])
        self.assertDictEqual(detailjson['information_desks'][0],
                             {u'description': u'<p>description 0</p>',
                              u'email': u'[email protected]',
                              u'latitude': -5.983593666147552,
                              u'longitude': -1.3630761286186646,
                              u'name': u'information desk name 0',
                              u'phone': u'01 02 03 0',
                              u'photo_url': self.information_desk.photo_url,
                              u'postal_code': 28300,
                              u'street': u'0 baker street',
                              u'municipality': u"Bailleau L'évêque-0",
                              u'website': u'http://makina-corpus.com/0'})
        self.assertEqual(detailjson['information_desk_layer'],
                         '/api/trek/%s/information_desks.geojson' % trek.pk)
        self.assertEqual(detailjson['filelist_url'],
                         '/paperclip/get/trekking/trek/%s/' % trek.pk)
开发者ID:fmerzeau,项目名称:Geotrek,代码行数:35,代码来源:test_views.py

示例8: test_poi_geojson_translation

 def test_poi_geojson_translation(self):
     # Create a Trek with a POI
     trek = TrekFactory.create(no_path=True)
     p1 = PathFactory.create(geom=LineString((0, 0), (4, 4)))
     poi = POIFactory.create(no_path=True)
     poi.name_fr = "Chapelle"
     poi.name_en = "Chapel"
     poi.name_it = "Capela"
     poi.published_fr = True
     poi.published_en = True
     poi.published_it = True
     poi.save()
     trek.add_path(p1, start=0.5)
     poi.add_path(p1, start=0.6, end=0.6)
     # Check that it applies to GeoJSON also :
     self.assertEqual(len(trek.pois), 1)
     poi = trek.pois[0]
     for lang, expected in [('fr-FR', poi.name_fr),
                            ('it-IT', poi.name_it)]:
         url = reverse('trekking:trek_poi_geojson', kwargs={'pk': trek.pk})
         self.login()
         response = self.client.get(url, HTTP_ACCEPT_LANGUAGE=lang)
         self.assertEqual(response.status_code, 200)
         obj = json.loads(response.content)
         jsonpoi = obj.get('features', [])[0]
         self.assertEqual(jsonpoi.get('properties', {}).get('name'), expected)
         self.client.logout()  # Django 1.6 keeps language in session
开发者ID:Babawah,项目名称:Geotrek,代码行数:27,代码来源:test_views.py

示例9: test_delete_cascade

    def test_delete_cascade(self):
        p1 = PathFactory.create()
        p2 = PathFactory.create()
        t = TrekFactory.create(no_path=True)
        t.add_path(p1)
        t.add_path(p2)

        # Everything should be all right before delete
        self.assertTrue(t.published)
        self.assertFalse(t.deleted)
        self.assertEqual(t.aggregations.count(), 2)

        # When a path is deleted
        p1.delete()
        t = Trek.objects.get(pk=t.pk)
        self.assertFalse(t.published)
        self.assertFalse(t.deleted)
        self.assertEqual(t.aggregations.count(), 1)

        # Reset published status
        t.published = True
        t.save()

        # When all paths are deleted
        p2.delete()
        t = Trek.objects.get(pk=t.pk)
        self.assertFalse(t.published)
        self.assertTrue(t.deleted)
        self.assertEqual(t.aggregations.count(), 0)
开发者ID:Babawah,项目名称:Geotrek,代码行数:29,代码来源:test_models.py

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

示例11: test_poi_geojson_translation

 def test_poi_geojson_translation(self):
     # Create a Trek with a POI
     trek = TrekFactory.create(no_path=True, published_fr=True, published_it=True)
     p1 = PathFactory.create(geom=LineString((0, 0), (4, 4)))
     poi = POIFactory.create(no_path=True)
     poi.name_fr = "Chapelle"
     poi.name_en = "Chapel"
     poi.name_it = "Capela"
     poi.published_fr = True
     poi.published_en = True
     poi.published_it = True
     poi.save()
     trek.add_path(p1, start=0.5)
     poi.add_path(p1, start=0.6, end=0.6)
     # Check that it applies to GeoJSON also :
     self.assertEqual(len(trek.pois), 1)
     poi = trek.pois[0]
     for lang, expected in [('fr', poi.name_fr),
                            ('it', poi.name_it)]:
         url = '/api/{lang}/treks/{pk}/pois.geojson'.format(lang=lang, pk=trek.pk)
         self.login()
         response = self.client.get(url)
         self.assertEqual(response.status_code, 200)
         obj = json.loads(response.content)
         jsonpoi = obj.get('features', [])[0]
         self.assertEqual(jsonpoi.get('properties', {}).get('name'), expected)
         self.client.logout()  # Django 1.6 keeps language in session
开发者ID:brianpessers,项目名称:Geotrek,代码行数:27,代码来源:test_views.py

示例12: test_helpers

    def test_helpers(self):
        trek = TrekFactory.create(no_path=True)
        p1 = PathFactory.create(geom=LineString((0, 0), (4, 4)))
        p2 = PathFactory.create(geom=LineString((4, 4), (8, 8)))
        poi = POIFactory.create(no_path=True)
        PathAggregationFactory.create(topo_object=trek, path=p1,
                                      start_position=0.5)
        PathAggregationFactory.create(topo_object=trek, path=p2)
        PathAggregationFactory.create(topo_object=poi, path=p1,
                                      start_position=0.6, end_position=0.6)
        # /!\ District are automatically linked to paths at DB level
        d1 = DistrictFactory.create(geom=MultiPolygon(
            Polygon(((-2, -2), (3, -2), (3, 3), (-2, 3), (-2, -2)))))

        # Ensure related objects are accessible
        self.assertItemsEqual(trek.pois, [poi])
        self.assertItemsEqual(poi.treks, [trek])
        self.assertItemsEqual(trek.districts, [d1])

        # Ensure there is no duplicates
        PathAggregationFactory.create(topo_object=trek, path=p1,
                                      end_position=0.5)
        self.assertItemsEqual(trek.pois, [poi])
        self.assertItemsEqual(poi.treks, [trek])

        d2 = DistrictFactory.create(geom=MultiPolygon(
            Polygon(((3, 3), (9, 3), (9, 9), (3, 9), (3, 3)))))
        self.assertItemsEqual(trek.districts, [d1, d2])
开发者ID:Babawah,项目名称:Geotrek,代码行数:28,代码来源:test_models.py

示例13: test_any_published_property

 def test_any_published_property(self):
     t = TrekFactory.create(published=False)
     t.published_fr = False
     t.published_it = False
     t.save()
     self.assertFalse(t.any_published)
     t.published_it = True
     t.save()
     self.assertTrue(t.any_published)
开发者ID:Babawah,项目名称:Geotrek,代码行数:9,代码来源:test_models.py

示例14: test_deleted_pois

 def test_deleted_pois(self):
     p1 = PathFactory.create(geom=LineString((0, 0), (4, 4)))
     trek = TrekFactory.create(no_path=True)
     trek.add_path(p1)
     poi = POIFactory.create(no_path=True)
     poi.add_path(p1, start=0.6, end=0.6)
     self.assertItemsEqual(trek.pois, [poi])
     poi.delete()
     self.assertItemsEqual(trek.pois, [])
开发者ID:Babawah,项目名称:Geotrek,代码行数:9,代码来源:test_models.py

示例15: test_trek_itself_as_parent

 def test_trek_itself_as_parent(self):
     """
     Test if a trek it is its own parent
     """
     trek1 = TrekFactory.create(name='trek1')
     OrderedTrekChild.objects.create(parent=trek1, child=trek1)
     self.assertRaisesMessage(ValidationError,
                              u"Cannot use itself as child trek.",
                              trek1.full_clean)
开发者ID:makinacorpus,项目名称:Geotrek,代码行数:9,代码来源:test_models.py


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