Ejemplo n.º 1
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())
Ejemplo n.º 2
0
 def get_good_data(self):
     return {
         'species': SpeciesFactory.create().pk,
         'geom':
         '{"type": "Polygon", "coordinates":[[[0, 0], [0, 1], [1, 0], [0, 0]]]}',
         'structure': str(self.user.profile.structure.pk),
     }
Ejemplo n.º 3
0
 def test_cli(self):
     filename = os.path.join(os.path.dirname(__file__), 'data',
                             'species.shp')
     call_command(
         'import',
         'geotrek.sensitivity.parsers.SpeciesSensitiveAreaShapeParser',
         filename,
         verbosity=0)
     self.assertEqual(SensitiveArea.objects.count(), 0)
     species = SpeciesFactory(name="Aigle royal")
     call_command(
         'import',
         'geotrek.sensitivity.parsers.SpeciesSensitiveAreaShapeParser',
         filename,
         verbosity=0)
     area = SensitiveArea.objects.first()
     self.assertEqual(area.species, species)
     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'))')
Ejemplo n.º 4
0
 def test_cli(self):
     filename = os.path.join(os.path.dirname(__file__), 'data',
                             'species.shp')
     call_command(
         'import',
         'geotrek.sensitivity.parsers.SpeciesSensitiveAreaShapeParser',
         filename,
         verbosity=0)
     self.assertEqual(SensitiveArea.objects.count(), 0)
     species = SpeciesFactory(name=u"Aigle royal")
     call_command(
         'import',
         'geotrek.sensitivity.parsers.SpeciesSensitiveAreaShapeParser',
         filename,
         verbosity=0)
     area = SensitiveArea.objects.first()
     self.assertEqual(area.species, species)
     self.assertEqual(area.contact, u"Contact")
     self.assertEqual(area.description, u"Test UTF8 éêè")
     self.assertEqual(
         area.geom.wkt,
         'POLYGON ((929315.3613368585 6483309.443505395, 929200.3539448172 6483204.020062691, '
         '928404.8861498644 6482494.80781177, 928194.0392644553 6482082.697990288, '
         '927925.6886830255 6481210.558600641, 927676.5060002692 6481287.230195334, '
         '927772.345493637 6481498.077080746, 927887.3528856783 6481900.60295289, '
         '928184.4553151187 6482600.231254471, 928625.3169846105 6483520.290390803, '
         '929162.0181474701 6483664.049630859, 929315.3613368585 6483309.443505395))'
     )
Ejemplo n.º 5
0
 def test_specific_radius(self):
     specie = SpeciesFactory.create(radius=50)
     sensitive_area = SensitiveAreaFactory.create(species=specie)
     self.assertEqual(sensitive_area.radius, 50)
Ejemplo n.º 6
0
 def test_specific_radius(self):
     specie = SpeciesFactory.create(radius=50)
     sensitive_area = SensitiveAreaFactory.create(species=specie)
     self.assertEqual(sensitive_area.radius, 50)
Ejemplo n.º 7
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())
Ejemplo n.º 8
0
 def get_good_data(self):
     return {
         'species': SpeciesFactory.create().pk,
         'structure': default_structure().pk,
         'geom': '{"type": "Polygon", "coordinates":[[[0, 0], [0, 1], [1, 0], [0, 0]]]}',
     }
Ejemplo n.º 9
0
 def get_good_data(self):
     return {
         'species': SpeciesFactory.create().pk,
         'geom': '{"type": "Polygon", "coordinates":[[[0, 0], [0, 1], [1, 0], [0, 0]]]}',
         'structure': str(self.user.profile.structure.pk),
     }