Example #1
0
 def get_good_data(self):
     return {
         'name': u'Test',
         'practices': [SportPracticeFactory.create().pk],
         'geom': '{"type": "Polygon", "coordinates":[[[0, 0], [0, 1], [1, 0], [0, 0]]]}',
         'structure': str(self.user.profile.structure.pk),
     }
Example #2
0
 def test_sync_with_multipolygon_sensitive_area(self):
     area = SensitiveAreaFactory.create(
         geom='MULTIPOLYGON(((0 0, 0 3, 3 3, 3 0, 0 0)))', published=True)
     area.species.practices.add(
         SportPracticeFactory.create(name='Terrestre'))
     area.save()
     management.call_command('sync_rando',
                             os.path.join('var', 'tmp'),
                             with_signages=True,
                             with_infrastructures=True,
                             with_dives=True,
                             with_events=True,
                             content_categories="1",
                             url='http://localhost:8000',
                             skip_tiles=True,
                             skip_pdf=True,
                             verbosity=2,
                             languages='en',
                             stdout=StringIO())
     with open(
             os.path.join('var', 'tmp', 'api', 'en',
                          'sensitiveareas.geojson'), 'r') as f:
         area = json.load(f)
         # there are 2 areas
         self.assertEqual(len(area['features']), 2)
Example #3
0
 def test_regulatory_sensitive_area_shape(self):
     filename = os.path.join(os.path.dirname(__file__), 'data',
                             'species_regu.shp')
     call_command(
         'import',
         'geotrek.sensitivity.parsers.RegulatorySensitiveAreaShapeParser',
         filename,
         verbosity=0)
     self.assertEqual(SensitiveArea.objects.count(), 0)
     SportPracticeFactory(name="sport")
     call_command(
         'import',
         'geotrek.sensitivity.parsers.RegulatorySensitiveAreaShapeParser',
         filename,
         verbosity=0)
     area = SensitiveArea.objects.first()
     self.assertEqual(str(area.species), "Nom")
     self.assertTrue(area.species.period10)
     self.assertTrue(area.species.period11)
     self.assertTrue(area.species.period12)
     self.assertFalse(area.species.period08)
     self.assertEqual(area.species.radius, 23)
     self.assertEqual(area.species.url, "http://test.com")
     self.assertEqual(area.contact, "Contact")
     self.assertEqual(area.description, "Test UTF8 éêè")
     self.assertEqual(
         WKTWriter(precision=7).write(area.geom), b'POLYGON (('
         b'929315.3613369 6483309.4435054, 929200.3539448 6483204.0200627, '
         b'928404.8861499 6482494.8078118, 928194.0392645 6482082.6979903, '
         b'927925.6886830 6481210.5586006, 927676.5060003 6481287.2301953, '
         b'927772.3454936 6481498.0770807, 927887.3528857 6481900.6029529, '
         b'928184.4553151 6482600.2312545, 928625.3169846 6483520.2903908, '
         b'929162.0181475 6483664.0496309, 929315.3613369 6483309.4435054'
         b'))')
Example #4
0
 def get_good_data(self):
     return {
         'name': u'Test',
         'practices': [SportPracticeFactory.create().pk],
         'geom': '{"type": "Polygon", "coordinates":[[[0, 0], [0, 1], [1, 0], [0, 0]]]}',
         'structure': str(self.user.profile.structure.pk),
     }
Example #5
0
 def setUp(self):
     super().setUp()
     self.information_desks = InformationDeskFactory.create()
     self.trek = TrekWithPublishedPOIsFactory.create(published=True)
     if settings.TREKKING_TOPOLOGY_ENABLED:
         InfrastructureFactory.create(paths=[(self.trek.paths.first(), 0, 0)
                                             ],
                                      name="INFRA_1")
         SignageFactory.create(paths=[(self.trek.paths.first(), 0, 0)],
                               name="SIGNA_1")
     else:
         InfrastructureFactory.create(
             geom='SRID=2154;POINT(700000 6600000)', name="INFRA_1")
         SignageFactory.create(geom='SRID=2154;POINT(700000 6600000)',
                               name="SIGNA_1")
     area = SensitiveAreaFactory.create(published=True)
     area.species.practices.add(
         SportPracticeFactory.create(name='Terrestre'))
     area.save()
     self.touristic_content = TouristicContentFactory(
         geom='SRID=%s;POINT(700001 6600001)' % settings.SRID,
         published=True)
     self.touristic_event = TouristicEventFactory(
         geom='SRID=%s;POINT(700001 6600001)' % settings.SRID,
         published=True)
     self.attachment_touristic_content = AttachmentFactory.create(
         content_object=self.touristic_content,
         attachment_file=get_dummy_uploaded_image())
     self.attachment_touristic_event = AttachmentFactory.create(
         content_object=self.touristic_event,
         attachment_file=get_dummy_uploaded_image())
     self.touristic_content_without_attachment = TouristicContentFactory(
         geom='SRID=%s;POINT(700002 6600002)' % settings.SRID,
         published=True)
     self.touristic_event_without_attachment = TouristicEventFactory(
         geom='SRID=%s;POINT(700002 6600002)' % settings.SRID,
         published=True)
Example #6
0
    def setUp(self):
        self.source_a = RecordSourceFactory()
        self.source_b = RecordSourceFactory()

        self.portal_a = TargetPortalFactory()
        self.portal_b = TargetPortalFactory()
        information_desks = InformationDeskFactory.create()

        self.practice_trek = PracticeTrekFactory.create(order=1)
        self.practice_trek_first = PracticeTrekFactory.create(order=0)
        self.trek_1 = TrekWithPublishedPOIsFactory.create(practice=self.practice_trek, sources=(self.source_a, ),
                                                          portals=(self.portal_b,),
                                                          published=True)
        self.trek_1.information_desks.add(information_desks)
        self.attachment_1 = AttachmentFactory.create(content_object=self.trek_1,
                                                     attachment_file=get_dummy_uploaded_image())
        self.trek_2 = TrekFactory.create(sources=(self.source_b,),
                                         published=True)
        self.trek_3 = TrekFactory.create(portals=(self.portal_b,
                                                  self.portal_a),
                                         published=True)
        self.trek_4 = TrekFactory.create(practice=self.practice_trek, portals=(self.portal_a,),
                                         published=True)
        self.trek_5 = TrekFactory.create(practice=self.practice_trek_first, portals=(self.portal_a,),
                                         published=True, name="other")

        self.practice_dive = PracticeDiveFactory.create(order=0)

        self.dive_1 = DiveFactory.create(practice=self.practice_dive, sources=(self.source_a,),
                                         portals=(self.portal_b,),
                                         published=True, geom='SRID=2154;POINT(700001 6600001)')
        self.attachment_dive = AttachmentFactory.create(content_object=self.dive_1,
                                                        attachment_file=get_dummy_uploaded_image())
        self.dive_2 = DiveFactory.create(sources=(self.source_b,),
                                         published=True, geom='SRID=2154;LINESTRING (700000 6600000, 700100 6600100)')
        self.dive_3 = DiveFactory.create(portals=(self.portal_b,
                                                  self.portal_a),
                                         published=True, geom='POLYGON((700000 6600000, 700000 6600100, '
                                                              '700100 6600100, 700100 6600000, 700000 6600000))')
        self.dive_4 = DiveFactory.create(practice=self.practice_dive, portals=(self.portal_a,),
                                         published=True)
        self.poi_1 = trek_models.POI.objects.first()
        self.poi_dive = POIFactory.create(name="dive_poi", published=True)
        self.attachment_poi_image_1 = AttachmentFactory.create(content_object=self.poi_1,
                                                               attachment_file=get_dummy_uploaded_image())
        AttachmentFactory.create(content_object=self.poi_dive,
                                 attachment_file=get_dummy_uploaded_image())
        self.attachment_poi_image_2 = AttachmentFactory.create(content_object=self.poi_1,
                                                               attachment_file=get_dummy_uploaded_image())
        AttachmentFactory.create(content_object=self.poi_dive,
                                 attachment_file=get_dummy_uploaded_file())
        self.attachment_poi_file = AttachmentFactory.create(content_object=self.poi_1,
                                                            attachment_file=get_dummy_uploaded_file())
        if settings.TREKKING_TOPOLOGY_ENABLED:
            infrastructure = InfrastructureFactory.create(no_path=True, name="INFRA_1")
            infrastructure.add_path(self.trek_1.paths.first(), start=0, end=0)
            signage = SignageFactory.create(no_path=True, name="SIGNA_1")
            signage.add_path(self.trek_1.paths.first(), start=0, end=0)
        else:
            InfrastructureFactory.create(geom='SRID=2154;POINT(700000 6600000)', name="INFRA_1")
            SignageFactory.create(geom='SRID=2154;POINT(700000 6600000)', name="SIGNA_1")
        area = SensitiveAreaFactory.create(published=True)
        area.species.practices.add(SportPracticeFactory.create(name='Terrestre'))
        area.save()
        self.touristic_content = TouristicContentFactory(
            geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, published=True)
        self.touristic_event = TouristicEventFactory(
            geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, published=True)
        self.attachment_touristic_content = AttachmentFactory.create(content_object=self.touristic_content,
                                                                     attachment_file=get_dummy_uploaded_image())
        self.attachment_touristic_event = AttachmentFactory.create(content_object=self.touristic_event,
                                                                   attachment_file=get_dummy_uploaded_image())