示例#1
0
    def setUp(self):
        self.user = SuperUserFactory.create(password='******')

        self.theme = ThemeFactory.create(label="Theme 1")
        self.theme_2 = ThemeFactory.create(label="Theme 2")
        self.theme_other = ThemeFactory.create(label="Autre theme")
        self.difficulty_1 = DifficultyLevelFactory.create(difficulty="Dif 1")
        self.difficulty_2 = DifficultyLevelFactory.create(difficulty="Dif 2")
        self.difficulty_3 = DifficultyLevelFactory.create(difficulty="Dif 3")
        self.trek = TrekFactory.create(
            geom='SRID=%s;LINESTRING(0 0, 1 0, 2 0)' % settings.SRID,
            difficulty=self.difficulty_2)
        self.trek.themes.add(self.theme, self.theme_2)
示例#2
0
 def themes(obj, create, extracted=None, **kwargs):
     if create:
         if extracted:
             for theme in extracted:
                 obj.themes.add(theme)
         else:
             obj.themes.add(ThemeFactory.create())
示例#3
0
 def test_sync_fail_src_file_not_exist(self):
     output = StringIO()
     theme = ThemeFactory.create()
     theme.pictogram = "other"
     theme.save()
     with self.assertRaisesRegexp(CommandError, 'Some errors raised during synchronization.'):
         management.call_command('sync_rando', 'tmp', url='http://localhost:8000',
                                 skip_tiles=True, languages='fr', verbosity=2, stdout=output, stderr=StringIO())
     self.assertIn("file does not exist", output.getvalue())
示例#4
0
    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',
        }
 def setUp(self):
     self.point1 = DiveFactory.create()
     self.point1.themes.add(ThemeFactory.create(label="Tag1"))
     self.point1.themes.add(ThemeFactory.create(label="Tag2"))
     self.line1 = DiveFactory.create(geom='SRID=%s;LINESTRING(0 0, 10 0)' %
                                     settings.SRID)
     self.multiline = DiveFactory.create(
         geom='SRID=%s;MULTILINESTRING((10 10, 20 20, 10 40),'
         '(40 40, 30 30, 40 20, 30 10))' % settings.SRID)
     self.multipoint = DiveFactory.create(
         geom='SRID=%s;MULTIPOINT((1 1), (2 2))' % settings.SRID)
     self.polygon = DiveFactory.create(
         geom='SRID=%s;POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))' % settings.SRID)
     self.multipolygon = DiveFactory.create(
         geom='SRID=%s;MULTIPOLYGON(((0 0, 0 1, 1 1, 1 0, 0 0)),'
         '((2 2, 2 3, 3 3, 3 2, 2 2)))' % settings.SRID)
     self.serializer = ZipShapeSerializer()
     response = HttpResponse()
     self.serializer.serialize(Dive.objects.all(),
                               stream=response,
                               fields=['id', 'name'],
                               delete=False)
示例#6
0
    def setUp(self):
        self.login()

        polygon = 'SRID=%s;MULTIPOLYGON(((0 0, 0 3, 3 3, 3 0, 0 0)))' % settings.SRID
        self.city = CityFactory(geom=polygon)
        self.district = DistrictFactory(geom=polygon)

        self.trek = TrekFactory.create(
            points_reference=MultiPoint([Point(0, 0), Point(1, 1)], srid=settings.SRID),
            parking_location=Point(0, 0, srid=settings.SRID)
        )

        self.attachment = AttachmentFactory.create(obj=self.trek,
                                                   attachment_file=get_dummy_uploaded_image())

        self.information_desk = tourism_factories.InformationDeskFactory.create()
        self.trek.information_desks.add(self.information_desk)

        self.usage = UsageFactory.create()
        self.trek.usages.add(self.usage)

        self.theme = ThemeFactory.create()
        self.trek.themes.add(self.theme)

        self.network = TrekNetworkFactory.create()
        self.trek.networks.add(self.network)

        self.weblink = WebLinkFactory.create()
        self.trek.web_links.add(self.weblink)

        self.trek_b = TrekFactory.create()
        TrekRelationshipFactory.create(has_common_departure=True,
                                       has_common_edge=False,
                                       is_circuit_step=True,
                                       trek_a=self.trek,
                                       trek_b=self.trek_b)

        self.touristic_content = tourism_factories.TouristicContentFactory(geom='SRID=%s;POINT(1 1)' % settings.SRID)
        self.touristic_event = tourism_factories.TouristicEventFactory(geom='SRID=%s;POINT(2 2)' % settings.SRID)

        self.pk = self.trek.pk
        url = '/api/treks/%s/' % self.pk
        self.response = self.client.get(url)
        self.result = json.loads(self.response.content)
示例#7
0
    def setUp(self):
        self.login()

        polygon = 'SRID=%s;MULTIPOLYGON(((0 0, 0 3, 3 3, 3 0, 0 0)))' % settings.SRID
        self.city = CityFactory(geom=polygon)
        self.district = DistrictFactory(geom=polygon)

        self.parent = TrekFactory.create(published=True)

        self.trek = TrekFactory.create(
            parent=self.parent,
            no_path=True,
            points_reference=MultiPoint([Point(0, 0), Point(1, 1)], srid=settings.SRID),
            parking_location=Point(0, 0, srid=settings.SRID)
        )
        path1 = PathFactory.create(geom='SRID=%s;LINESTRING(0 0, 1 0)' % settings.SRID)
        self.trek.add_path(path1)

        self.attachment = AttachmentFactory.create(obj=self.trek,
                                                   attachment_file=get_dummy_uploaded_image())

        self.information_desk = tourism_factories.InformationDeskFactory.create()
        self.trek.information_desks.add(self.information_desk)

        self.theme = ThemeFactory.create()
        self.trek.themes.add(self.theme)

        self.accessibility = AccessibilityFactory.create()
        self.trek.accessibilities.add(self.accessibility)

        self.network = TrekNetworkFactory.create()
        self.trek.networks.add(self.network)

        self.weblink = WebLinkFactory.create()
        self.trek.web_links.add(self.weblink)

        self.source = RecordSourceFactory.create()
        self.trek.source.add(self.source)

        self.trek_b = TrekFactory.create(no_path=True,
                                         geom='SRID=%s;POINT(2 2)' % settings.SRID,
                                         published=True)
        path2 = PathFactory.create(geom='SRID=%s;LINESTRING(0 1, 1 1)' % settings.SRID)
        self.trek_b.add_path(path2)
        TrekRelationshipFactory.create(has_common_departure=True,
                                       has_common_edge=False,
                                       is_circuit_step=True,
                                       trek_a=self.trek,
                                       trek_b=self.trek_b)

        self.touristic_content = tourism_factories.TouristicContentFactory(geom='SRID=%s;POINT(1 1)' % settings.SRID, published=True)
        tourism_factories.TouristicContentFactory(geom='SRID=%s;POINT(1 1)' % settings.SRID, published=False)  # not published
        tourism_factories.TouristicContentFactory(geom='SRID=%s;POINT(1 1)' % settings.SRID, published=True).delete()  # deleted
        tourism_factories.TouristicContentFactory(geom='SRID=%s;POINT(1000 1000)' % settings.SRID, published=True)  # too far
        self.touristic_event = tourism_factories.TouristicEventFactory(geom='SRID=%s;POINT(2 2)' % settings.SRID, published=True)
        tourism_factories.TouristicEventFactory(geom='SRID=%s;POINT(2 2)' % settings.SRID, published=False)  # not published
        tourism_factories.TouristicEventFactory(geom='SRID=%s;POINT(2 2)' % settings.SRID, published=True).delete()  # deleted
        tourism_factories.TouristicEventFactory(geom='SRID=%s;POINT(2000 2000)' % settings.SRID, published=True)  # too far
        trek2 = TrekFactory(no_path=True, published=False)  # not published
        trek2.add_path(path2)
        trek3 = TrekFactory(no_path=True, published=True)  # deleted
        trek3.add_path(path2)
        trek3.delete()
        trek4 = TrekFactory(no_path=True, published=True)  # too far
        trek4.add_path(PathFactory.create(geom='SRID=%s;LINESTRING(0 2000, 1 2000)' % settings.SRID))

        self.child1 = TrekFactory.create(published=False, parent=self.trek)
        self.child2 = TrekFactory.create(published=True, parent=self.trek)

        self.pk = self.trek.pk
        url = '/api/treks/%s/' % self.pk
        self.response = self.client.get(url)
        self.result = json.loads(self.response.content)
 def setUp(self):
     self.point = DiveFactory.create(name="Test")
     self.point.themes.add(ThemeFactory.create(label="Tag1"))
     self.point.themes.add(ThemeFactory.create(label="Tag2"))
     self.serializer = CSVSerializer()
     self.stream = StringIO()