Exemplo n.º 1
0
 def test_filters_no_period_get_month(self):
     sensitive_area_month = SensitiveAreaFactory.create(**{'species__period01': True})
     SensitiveAreaFactory.create(**{'species__period02': True})
     url = '/api/v2/sensitivearea/?format=json&language=en'
     response = self.client.get(url)
     self.assertEqual(response.json()['count'], 1)
     self.assertEqual(response.json()['results'][0]['name'], sensitive_area_month.species.name)
Exemplo n.º 2
0
 def test_filters_specific_period(self):
     sensitive_area_jf = SensitiveAreaFactory.create(species__period01=True, species__period02=True)
     SensitiveAreaFactory.create(species__period01=True)
     SensitiveAreaFactory.create(species__period04=True)
     url = '/api/v2/sensitivearea/?format=json&language=en&period=2,3'
     response = self.client.get(url)
     self.assertEqual(response.json()['count'], 1)
     self.assertEqual(response.json()['results'][0]['name'], sensitive_area_jf.species.name)
Exemplo n.º 3
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.trek_1 = TrekWithPublishedPOIsFactory.create(
            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(portals=(self.portal_a, ),
                                         published=True)

        self.poi_1 = trek_models.POI.objects.first()
        self.attachment_poi_image_1 = AttachmentFactory.create(
            content_object=self.poi_1,
            attachment_file=get_dummy_uploaded_image())
        self.attachment_poi_image_2 = AttachmentFactory.create(
            content_object=self.poi_1,
            attachment_file=get_dummy_uploaded_image())
        self.attachment_poi_file = AttachmentFactory.create(
            content_object=self.poi_1,
            attachment_file=get_dummy_uploaded_file())

        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)
        SensitiveAreaFactory.create(published=True)
        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())
Exemplo n.º 4
0
 def setUp(self):
     profile = UserProfileFactory.create(user__username='******',
                                         user__password='******')
     user = profile.user
     user.user_permissions.add(Permission.objects.get(codename=u"add_sensitivearea"))
     user.user_permissions.add(Permission.objects.get(codename=u"change_sensitivearea"))
     user.user_permissions.add(Permission.objects.get(codename=u"delete_sensitivearea"))
     user.user_permissions.add(Permission.objects.get(codename=u"read_sensitivearea"))
     user.user_permissions.add(Permission.objects.get(codename=u"export_sensitivearea"))
     self.client.login(username=user.username, password='******')
     self.area1 = SensitiveAreaFactory.create()
     structure = StructureFactory.create()
     self.area2 = SensitiveAreaFactory.create(structure=structure)
Exemplo n.º 5
0
 def setUp(self):
     profile = UserProfileFactory.create(user__username='******',
                                         user__password='******')
     user = profile.user
     user.user_permissions.add(Permission.objects.get(codename="add_sensitivearea"))
     user.user_permissions.add(Permission.objects.get(codename="change_sensitivearea"))
     user.user_permissions.add(Permission.objects.get(codename="delete_sensitivearea"))
     user.user_permissions.add(Permission.objects.get(codename="read_sensitivearea"))
     user.user_permissions.add(Permission.objects.get(codename="export_sensitivearea"))
     self.client.login(username=user.username, password='******')
     self.area1 = SensitiveAreaFactory.create()
     structure = StructureFactory.create()
     self.area2 = SensitiveAreaFactory.create(structure=structure)
Exemplo n.º 6
0
 def test_filters_structure(self):
     other_structure = StructureFactory.create(name='other')
     self.sensitivearea_other_structure = SensitiveAreaFactory.create(structure=other_structure)
     url = '/api/v2/sensitivearea/?format=json&language=en&period=ignore&structures={}'.format(other_structure.pk)
     response = self.client.get(url)
     self.assertEqual(response.json()['count'], 1)
     self.assertEqual(response.json()['results'][0]['name'], self.sensitivearea_other_structure.species.name)
Exemplo n.º 7
0
 def test_trek_sensitive_area(self):
     """
     The area intersects 6 times the trek : we should get only one time this area.
     issue #2010
     """
     SensitiveAreaFactory.create()
     SensitiveAreaFactory.create(
         geom="Polygon ((700000 6600000, 699994.87812128441873938 6600014.35493460204452276, 700021.84601664706133306"
              " 6600008.61177170090377331, 700013.10642092768102884 6600028.83769322279840708, 700044.81866825232282281"
              " 6600017.85077288933098316, 700030.83531510119792074 6600042.32164090406149626, 700061.79845422133803368"
              " 6600043.07074910867959261, 700061.04934601683635265 6600069.78894173633307219, 700075.78180737234652042"
              " 6600056.55469678994268179, 700072.53567181946709752 6600088.01724137924611568, 700092.26218787173274904"
              " 6600081.27526753861457109, 700090.01486325822770596 6600097.75564803835004568, 700100 6600100, "
              "700100 6600000, 700000 6600000))")
     trek = TrekFactory.create()
     self.assertEqual(trek.published_sensitive_areas.count(), 2)
Exemplo n.º 8
0
 def test_get_kml(self):
     species = SpeciesFactory.create(radius=5)
     sensitive_area = SensitiveAreaFactory.create(species=species)
     self.assertIn(
         '<coordinates>3.0,46.5,5.0 3.0,46.500027,5.0 3.0000391,46.500027,5.0 '
         '3.0000391,46.5,5.0 3.0,46.5,5.0</coordinates>',
         sensitive_area.kml())
Exemplo n.º 9
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)
Exemplo n.º 10
0
 def setUp(self):
     super(TrekkingManagerTest, self).setUp()
     self.sensitivearea = SensitiveAreaFactory.create()
     self.species = self.sensitivearea.species
     self.pk = self.sensitivearea.pk
     url = '/api/en/sensitiveareas/{pk}.json'.format(pk=self.pk)
     self.response = self.client.get(url)
     self.result = json.loads(self.response.content)
Exemplo n.º 11
0
 def test_get_extent(self):
     sensitive_area = SensitiveAreaFactory.create(
         geom=
         'POLYGON((700000 6600000, 700000 6600100, 700100 6600100, 700100 6600000, 700000 6600000))'
     )
     self.assertEqual(
         sensitive_area.extent,
         (3.0, 46.49999999256511, 3.0013039767202154, 46.500900449784226))
Exemplo n.º 12
0
 def test_get_extent(self):
     sensitive_area = SensitiveAreaFactory.create(
         geom='POLYGON((700000 6600000, 700000 6600100, 700100 6600100, 700100 6600000, 700000 6600000))')
     lng_min, lat_min, lng_max, lat_max = sensitive_area.extent
     self.assertAlmostEqual(lng_min, 3)
     self.assertAlmostEqual(lat_min, 46.5)
     self.assertAlmostEqual(lng_max, 3.00130397)
     self.assertAlmostEqual(lat_max, 46.50090044)
Exemplo n.º 13
0
 def test_list_bubble_sensitivearea_with_point(self):
     sensitive_area_point = SensitiveAreaFactory.create(geom='SRID=2154;POINT (700040 6600040)',
                                                        species__period01=True, species__radius=5)
     url = '/api/v2/sensitivearea/?format=json&period=ignore&language=en&bubble=True&period=1'
     response = self.client.get(url)
     self.assertEqual(response.json()['count'], 1)
     self.assertEqual(response.json()['results'][0]['radius'], 5)
     self.assertEqual(response.json()['results'][0]['name'], sensitive_area_point.species.name)
Exemplo n.º 14
0
 def test_get_extent(self):
     sensitive_area = SensitiveAreaFactory.create(
         geom=
         'POLYGON((700000 6600000, 700000 6600100, 700100 6600100, 700100 6600000, 700000 6600000))'
     )
     self.assertAlmostEqual(sensitive_area.extent[0], 3)
     self.assertAlmostEqual(sensitive_area.extent[1], 46.5)
     self.assertAlmostEqual(sensitive_area.extent[2], 3.00130397)
     self.assertAlmostEqual(sensitive_area.extent[3], 46.50090044)
Exemplo n.º 15
0
 def test_get_kml_point(self):
     sensitive_area = SensitiveAreaFactory.create(geom='POINT(700000 6600000)')
     # Create a buffer around the point with 100 (settings.SENSITIVITY_DEFAULT_RADIUS)
     self.assertIn('<coordinates>3.00130395519,46.4999999926,0.0 3.0012046899,46.4996554064,0.0 3.00092202479,'
                   '46.4993632821,0.0 3.00049899443,46.4991680917,0.0 3.0,46.4990995501,0.0 2.99950100557,'
                   '46.4991680917,0.0 2.99907797521,46.4993632821,0.0 2.9987953101,46.4996554064,0.0 2.99869604481,'
                   '46.4999999926,0.0 2.99879529488,46.5003445809,0.0 2.99907795368,46.5006367104,0.0 2.99950099034,'
                   '46.500831906,0.0 3.0,46.5009004498,0.0 3.00049900966,46.500831906,0.0 3.00092204632,'
                   '46.5006367104,0.0 3.00120470512,46.5003445809,0.0 3.00130395519,46.4999999926,0.0</coordinates>',
                   sensitive_area.kml())
Exemplo n.º 16
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.trek_1 = TrekWithPublishedPOIsFactory.create(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(portals=(self.portal_a,),
                                         published=True)

        self.poi_1 = trek_models.POI.objects.first()
        self.attachment_poi_image_1 = AttachmentFactory.create(content_object=self.poi_1,
                                                               attachment_file=get_dummy_uploaded_image())
        self.attachment_poi_image_2 = AttachmentFactory.create(content_object=self.poi_1,
                                                               attachment_file=get_dummy_uploaded_image())
        self.attachment_poi_file = AttachmentFactory.create(content_object=self.poi_1,
                                                            attachment_file=get_dummy_uploaded_file())

        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)
        SensitiveAreaFactory.create(published=True)
        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())
Exemplo n.º 17
0
 def test_get_kml_point(self):
     sensitive_area = SensitiveAreaFactory.create(geom='POINT(700000 6600000)')
     # Create a buffer around the point with 100 (settings.SENSITIVITY_DEFAULT_RADIUS)
     self.assertIn('<coordinates>'
                   '3.001304,46.5,0.0 3.0012047,46.4996554,0.0 3.000922,46.4993633,0.0 '
                   '3.000499,46.4991681,0.0 3.0,46.4990996,0.0 2.999501,46.4991681,0.0 '
                   '2.999078,46.4993633,0.0 2.9987953,46.4996554,0.0 2.998696,46.5,0.0 '
                   '2.9987953,46.5003446,0.0 2.999078,46.5006367,0.0 2.999501,46.5008319,0.0 '
                   '3.0,46.5009004,0.0 3.000499,46.5008319,0.0 3.000922,46.5006367,0.0 '
                   '3.0012047,46.5003446,0.0 3.001304,46.5,0.0'
                   '</coordinates>',
                   sensitive_area.kml())
Exemplo n.º 18
0
 def setUp(self):
     super(TrekkingManagerTest, self).setUp()
     self.sensitivearea = SensitiveAreaFactory.create()
     self.species = self.sensitivearea.species
     self.pk = self.sensitivearea.pk
     self.expected_properties = {
         'create_datetime': self.sensitivearea.date_insert.isoformat().replace('+00:00', 'Z'),
         'update_datetime': self.sensitivearea.date_update.isoformat().replace('+00:00', 'Z'),
         'description': "Blabla",
         "elevation": None,
         'contact': '<a href="mailto:[email protected]">[email protected]</a>',
         'kml_url': 'http://testserver/api/en/sensitiveareas/{pk}.kml'.format(pk=self.pk),
         'info_url': self.species.url,
         'species_id': self.species.id,
         "name": self.species.name,
         "period": [False, False, False, False, False, True, True, False, False, False, False, False],
         'practices': [p.pk for p in self.species.practices.all()],
         'structure': 'My structure',
         'published': True,
     }
     self.expected_geom = {
         'type': 'Polygon',
         'coordinates': [[
             [3.0, 46.5],
             [3.0, 46.500027],
             [3.0000391, 46.500027],
             [3.0000391, 46.5],
             [3.0, 46.5],
         ]],
     }
     self.expected_result = dict(self.expected_properties)
     self.expected_result['id'] = self.pk
     self.expected_result['geometry'] = self.expected_geom
     self.expected_result['url'] = 'http://testserver/api/v2/sensitivearea/{}/?format=json'.format(self.pk)
     self.expected_geo_result = {
         'bbox': [3.0, 46.5, 3.0000391, 46.500027],
         'geometry': self.expected_geom,
         'type': 'Feature',
         'id': self.pk,
         'properties': dict(self.expected_properties),
     }
     self.expected_geo_result['properties']['url'] = 'http://testserver/api/v2/sensitivearea/{}/?format=geojson'.format(self.pk)
Exemplo n.º 19
0
 def setUp(self):
     super(TrekkingManagerTest, self).setUp()
     self.sensitivearea = SensitiveAreaFactory.create()
     self.species = self.sensitivearea.species
     self.pk = self.sensitivearea.pk
     self.expected_properties = {
         u'create_datetime': unicode(self.sensitivearea.date_insert.isoformat().replace('+00:00', 'Z')),
         u'update_datetime': unicode(self.sensitivearea.date_update.isoformat().replace('+00:00', 'Z')),
         u'description': u"Blabla",
         u"elevation": None,
         u'contact': u'<a href="mailto:[email protected]">[email protected]</a>',
         u'kml_url': u'http://testserver/api/en/sensitiveareas/{pk}.kml'.format(pk=self.pk),
         u'info_url': self.species.url,
         u'species_id': self.species.id,
         u"name": self.species.name,
         u"period": [False, False, False, False, False, True, True, False, False, False, False, False],
         u'practices': [p.pk for p in self.species.practices.all()],
         u'structure': u'PNX',
         u'published': True,
     }
     self.expected_geom = {
         u'type': u'Polygon',
         u'coordinates': [[
             [3.0000000000000004, 46.49999999999995],
             [3.0000000000000004, 46.50002701349549],
             [3.0000391186749895, 46.5000270134888],
             [3.00003911865561, 46.49999999999326],
             [3.0000000000000004, 46.49999999999995],
         ]],
     }
     self.expected_result = dict(self.expected_properties)
     self.expected_result[u'id'] = self.pk
     self.expected_result[u'geometry'] = self.expected_geom
     self.expected_result[u'url'] = u'http://testserver/api/v2/sensitivearea/{}/?format=json'.format(self.pk)
     self.expected_geo_result = {
         u'bbox': [3.0, 46.49999999999325, 3.0000391186749886, 46.500027013495476],
         u'geometry': self.expected_geom,
         u'type': u'Feature',
         u'id': self.pk,
         u'properties': dict(self.expected_properties),
     }
     self.expected_geo_result[u'properties'][u'url'] = u'http://testserver/api/v2/sensitivearea/{}/?format=geojson'.format(self.pk)
Exemplo n.º 20
0
 def setUp(self):
     super(TrekkingManagerTest, self).setUp()
     self.sensitivearea = SensitiveAreaFactory.create()
     self.species = self.sensitivearea.species
     self.pk = self.sensitivearea.pk
     self.expected_properties = {
         u'publication_date': unicode(self.sensitivearea.publication_date.strftime('%Y-%m-%d')),
         u'published': True,
         u'description': u"Blabla",
         u'contact': u'<a href="mailto:[email protected]">[email protected]</a>',
         u'kml_url': u'/api/en/sensitiveareas/{pk}.kml'.format(pk=self.pk),
         u'species': {
             u"id": self.species.id,
             u"name": self.species.name,
             u'pictogram': os.path.join(settings.MEDIA_URL, self.species.pictogram.name),
             u"period": [False, False, False, False, False, True, True, False, False, False, False, False],
             u'practices': [
                 {u'id': self.species.practices.all()[0].pk, u'name': self.species.practices.all()[0].name},
                 {u'id': self.species.practices.all()[1].pk, u'name': self.species.practices.all()[1].name},
             ],
             u'url': self.species.url,
         },
     }
     self.expected_geom = {
         u'type': u'Polygon',
         u'coordinates': [[
             [3.0000000000000004, 46.49999999999995],
             [3.0000000000000004, 46.50002701349549],
             [3.0000391186749895, 46.5000270134888],
             [3.00003911865561, 46.49999999999326],
             [3.0000000000000004, 46.49999999999995],
         ]],
     }
     self.expected_result = dict(self.expected_properties)
     self.expected_result['id'] = self.pk
     self.expected_result['geometry'] = self.expected_geom
     self.expected_geo_result = {
         'geometry': self.expected_geom,
         'type': 'Feature',
         'id': self.pk,
         'properties': self.expected_properties,
     }
Exemplo n.º 21
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)
Exemplo n.º 22
0
 def test_get_lang_not_published(self):
     sensitive_area = SensitiveAreaFactory.create()
     sensitive_area.published = False
     self.assertEqual(sensitive_area.published_langs, [])
Exemplo n.º 23
0
 def test_no_radius(self):
     sensitive_area = SensitiveAreaFactory.create()
     self.assertEqual(sensitive_area.radius, settings.SENSITIVITY_DEFAULT_RADIUS)
Exemplo n.º 24
0
 def test_get_lang_published(self):
     sensitive_area = SensitiveAreaFactory.create()
     self.assertEqual(sensitive_area.published_langs, list(settings.MODELTRANSLATION_LANGUAGES))
Exemplo n.º 25
0
 def test_get_lang_not_published(self):
     sensitive_area = SensitiveAreaFactory.create()
     sensitive_area.published = False
     self.assertEqual(sensitive_area.published_langs, [])
Exemplo n.º 26
0
 def test_specific_radius(self):
     specie = SpeciesFactory.create(radius=50)
     sensitive_area = SensitiveAreaFactory.create(species=specie)
     self.assertEqual(sensitive_area.radius, 50)
Exemplo n.º 27
0
 def test_get_kml(self):
     species = SpeciesFactory.create(radius=5)
     sensitive_area = SensitiveAreaFactory.create(species=species)
     self.assertIn('<coordinates>3.0,46.5,5.0 3.0,46.5000270135,5.0 3.00003911867,46.5000270135,5.0 3.00003911866,'
                   '46.5,5.0 3.0,46.5,5.0</coordinates>', sensitive_area.kml())
Exemplo n.º 28
0
 def test_get_extent(self):
     sensitive_area = SensitiveAreaFactory.create(
         geom='POLYGON((700000 6600000, 700000 6600100, 700100 6600100, 700100 6600000, 700000 6600000))')
     self.assertEqual(sensitive_area.extent,
                      (3.0, 46.49999999256511, 3.0013039767202154, 46.500900449784226))
Exemplo n.º 29
0
 def test_is_public(self):
     sensitive_area = SensitiveAreaFactory.create()
     self.assertTrue(sensitive_area.is_public())
     sensitive_area.published = False
     self.assertFalse(sensitive_area.is_public())
Exemplo n.º 30
0
 def test_is_public(self):
     sensitive_area = SensitiveAreaFactory.create()
     self.assertTrue(sensitive_area.is_public())
     sensitive_area.published = False
     self.assertFalse(sensitive_area.is_public())
Exemplo n.º 31
0
 def setUp(self):
     super(TrekkingManagerTest, self).setUp()
     self.sensitivearea = SensitiveAreaFactory.create()
     self.species = self.sensitivearea.species
     self.pk = self.sensitivearea.pk
     self.expected_properties = {
         u'publication_date':
         unicode(self.sensitivearea.publication_date.strftime('%Y-%m-%d')),
         u'published':
         True,
         u'description':
         u"Blabla",
         u'contact':
         u'<a href="mailto:[email protected]">[email protected]</a>',
         u'kml_url':
         u'/api/en/sensitiveareas/{pk}.kml'.format(pk=self.pk),
         u'species': {
             u"id":
             self.species.id,
             u"name":
             self.species.name,
             u'pictogram':
             os.path.join(settings.MEDIA_URL, self.species.pictogram.name),
             u"period": [
                 False, False, False, False, False, True, True, False,
                 False, False, False, False
             ],
             u'practices': [
                 {
                     u'id': self.species.practices.all()[0].pk,
                     u'name': self.species.practices.all()[0].name
                 },
                 {
                     u'id': self.species.practices.all()[1].pk,
                     u'name': self.species.practices.all()[1].name
                 },
             ],
             u'url':
             self.species.url,
         },
     }
     self.expected_geom = {
         u'type':
         u'Polygon',
         u'coordinates': [[
             [3.0000000000000004, 46.49999999999995],
             [3.0000000000000004, 46.50002701349549],
             [3.0000391186749895, 46.5000270134888],
             [3.00003911865561, 46.49999999999326],
             [3.0000000000000004, 46.49999999999995],
         ]],
     }
     self.expected_result = dict(self.expected_properties)
     self.expected_result['id'] = self.pk
     self.expected_result['geometry'] = self.expected_geom
     self.expected_geo_result = {
         'geometry': self.expected_geom,
         'type': 'Feature',
         'id': self.pk,
         'properties': self.expected_properties,
     }
Exemplo n.º 32
0
 def test_get_lang_published(self):
     sensitive_area = SensitiveAreaFactory.create()
     self.assertEqual(sensitive_area.published_langs, list(settings.MODELTRANSLATION_LANGUAGES))
Exemplo n.º 33
0
 def setUp(self):
     self.area = SensitiveAreaFactory.create()
     self.login()
Exemplo n.º 34
0
 def setUp(self):
     super(TrekkingManagerTest, self).setUp()
     self.sensitivearea = SensitiveAreaFactory.create()
     self.species = self.sensitivearea.species
     self.pk = self.sensitivearea.pk
     self.expected_properties = {
         u'create_datetime':
         unicode(self.sensitivearea.date_insert.isoformat().replace(
             '+00:00', 'Z')),
         u'update_datetime':
         unicode(self.sensitivearea.date_update.isoformat().replace(
             '+00:00', 'Z')),
         u'description':
         u"Blabla",
         u"elevation":
         None,
         u'contact':
         u'<a href="mailto:[email protected]">[email protected]</a>',
         u'kml_url':
         u'http://testserver/api/en/sensitiveareas/{pk}.kml'.format(
             pk=self.pk),
         u'info_url':
         self.species.url,
         u'species_id':
         self.species.id,
         u"name":
         self.species.name,
         u"period": [
             False, False, False, False, False, True, True, False, False,
             False, False, False
         ],
         u'practices': [p.pk for p in self.species.practices.all()],
         u'structure':
         u'PNX',
         u'published':
         True,
     }
     self.expected_geom = {
         u'type':
         u'Polygon',
         u'coordinates': [[
             [3.0000000000000004, 46.49999999999995],
             [3.0000000000000004, 46.50002701349549],
             [3.0000391186749895, 46.5000270134888],
             [3.00003911865561, 46.49999999999326],
             [3.0000000000000004, 46.49999999999995],
         ]],
     }
     self.expected_result = dict(self.expected_properties)
     self.expected_result[u'id'] = self.pk
     self.expected_result[u'geometry'] = self.expected_geom
     self.expected_result[
         u'url'] = u'http://testserver/api/v2/sensitivearea/{}/?format=json'.format(
             self.pk)
     self.expected_geo_result = {
         u'bbox':
         [3.0, 46.49999999999325, 3.0000391186749886, 46.500027013495476],
         u'geometry':
         self.expected_geom,
         u'type':
         u'Feature',
         u'id':
         self.pk,
         u'properties':
         dict(self.expected_properties),
     }
     self.expected_geo_result[u'properties'][
         u'url'] = u'http://testserver/api/v2/sensitivearea/{}/?format=geojson'.format(
             self.pk)
Exemplo n.º 35
0
 def test_no_radius(self):
     sensitive_area = SensitiveAreaFactory.create()
     self.assertEqual(sensitive_area.radius, settings.SENSITIVITY_DEFAULT_RADIUS)
Exemplo n.º 36
0
 def test_get_kml(self):
     sensitive_area = SensitiveAreaFactory.create()
     self.assertIn(
         '<coordinates>3.0,46.5,0.0 3.0,46.5000270135,0.0 3.00003911867,46.5000270135,0.0 3.00003911866,'
         '46.5,0.0 3.0,46.5,0.0</coordinates>', sensitive_area.kml())
Exemplo n.º 37
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())
Exemplo n.º 38
0
 def test_specific_radius(self):
     specie = SpeciesFactory.create(radius=50)
     sensitive_area = SensitiveAreaFactory.create(species=specie)
     self.assertEqual(sensitive_area.radius, 50)
Exemplo n.º 39
0
 def setUp(self):
     self.area = SensitiveAreaFactory.create()
     self.login()
Exemplo n.º 40
0
 def test_filters_any_period(self):
     SensitiveAreaFactory.create()
     url = '/api/v2/sensitivearea/?format=json&language=en&period=any'
     response = self.client.get(url)
     self.assertEqual(response.json()['count'], 2)
Exemplo n.º 41
0
 def setUpClass(cls):
     super(SyncRandoTestCase, cls).setUpClass()
     cls.area = SensitiveAreaFactory.create(published=True)