Exemplo n.º 1
0
    def test_city_departure_nds(self):
        trek = TrekFactory.create(geom=LineString((0, 0), (5, 5)))
        self.assertEqual(trek.city_departure, '')

        city1 = CityFactory.create(geom=MultiPolygon(Polygon(((-1, -1), (3, -1), (3, 3),
                                                              (-1, 3), (-1, -1)))))
        city2 = CityFactory.create(geom=MultiPolygon(Polygon(((3, 3), (9, 3), (9, 9),
                                                              (3, 9), (3, 3)))))
        self.assertEqual([city for city in trek.cities], [city1, city2])
        self.assertEqual(trek.city_departure, str(city1))
Exemplo n.º 2
0
    def test_city_departure(self):
        trek = TrekFactory.create(no_path=True)
        p1 = PathFactory.create(geom=LineString((0, 0), (5, 5)))
        trek.add_path(p1)
        self.assertEqual(trek.city_departure, '')

        city1 = CityFactory.create(geom=MultiPolygon(Polygon(((-1, -1), (3, -1), (3, 3),
                                                              (-1, 3), (-1, -1)))))
        city2 = CityFactory.create(geom=MultiPolygon(Polygon(((3, 3), (9, 3), (9, 9),
                                                              (3, 9), (3, 3)))))
        self.assertEqual(trek.cities, [city1, city2])
        self.assertEqual(trek.city_departure, unicode(city1))
Exemplo n.º 3
0
    def test_city_departure(self):
        trek = TrekFactory.create(no_path=True)
        p1 = PathFactory.create(geom=LineString((0, 0), (5, 5)))
        trek.add_path(p1)
        self.assertEqual(trek.city_departure, '')

        city1 = CityFactory.create(geom=MultiPolygon(Polygon(((-1, -1), (3, -1), (3, 3),
                                                              (-1, 3), (-1, -1)))))
        city2 = CityFactory.create(geom=MultiPolygon(Polygon(((3, 3), (9, 3), (9, 9),
                                                              (3, 9), (3, 3)))))
        self.assertEqual(trek.cities, [city1, city2])
        self.assertEqual(trek.city_departure, unicode(city1))
Exemplo n.º 4
0
 def test_unpublish_city(self):
     self.login()
     CityFactory.create(published=True)
     CityFactory.create(published=False)
     data = {
         'action': 'unpublish',
         '_selected_action': City.objects.all().values_list('pk', flat=True)
     }
     self.client.post(reverse("admin:zoning_city_changelist"),
                      data,
                      follow=True)
     self.assertEqual(City.objects.filter(published=False).count(), 2)
Exemplo n.º 5
0
    def test_cities(self):
        city = CityFactory.create(published=False, geom=self.geom_2_wkt)

        self.assertQuerysetEqual(self.path.cities,
                                 [repr(self.city), repr(city)])
        self.assertEqual(len(self.path.cities), 2)
        self.assertQuerysetEqual(self.path.published_cities,
                                 [repr(self.city), repr(city)])
        self.assertEqual(len(self.path.published_cities), 2)

        self.assertQuerysetEqual(self.trek.cities,
                                 [repr(self.city), repr(city)])
        self.assertEqual(len(self.trek.cities), 2)
        self.assertQuerysetEqual(
            self.trek.published_cities,
            [repr(self.city)],
        )
        self.assertEqual(len(self.trek.published_cities), 1)

        # Check reverse order
        self.path.reverse()
        self.path.save()

        self.assertQuerysetEqual(self.path.cities,
                                 [repr(city), repr(self.city)])
        self.assertEqual(len(self.path.cities), 2)
        self.assertQuerysetEqual(self.path.published_cities,
                                 [repr(city), repr(self.city)])
        self.assertEqual(len(self.path.published_cities), 2)
Exemplo n.º 6
0
 def test_filter_out_city(self):
     filter = ProjectFilterSet(
         data={'city': [CityFactory.create(geom=self.geom_zoning)]})
     project_out = ProjectFactory.create()
     project_out.interventions.add(self.intervention_out)
     self.assertTrue(filter.is_valid())
     self.assertEqual(len(filter.qs), 0)
Exemplo n.º 7
0
 def test_serve_attachment_model_nomapentity(self):
     obj = CityFactory.create(code=1)
     attachment = AttachmentFactory.create(content_object=obj)
     request = RequestFactory().get('/fake-path')
     request.user = User.objects.create_superuser('test', '*****@*****.**',
                                                  'booh')
     with self.assertRaises(Http404):
         serve_attachment(request, str(attachment.attachment_file))
Exemplo n.º 8
0
 def test_city(self):
     city = CityFactory.create(name="Are",
                               code='09000',
                               geom=MultiPolygon(
                                   Polygon(((200, 0), (300, 0), (300, 100),
                                            (200, 100), (200, 0)),
                                           srid=settings.SRID)))
     self.assertEqual(str(city), "Are")
Exemplo n.º 9
0
 def test_intersection_zoning(self):
     self.modelfactory.create()
     CityFactory.create(name="Are", code='09000',
                        geom=MultiPolygon(Polygon(((0, 0), (300, 0), (300, 100), (200, 100), (0, 0)),
                                                  srid=settings.SRID)))
     CityFactory.create(name="Nor", code='09001',
                        geom=MultiPolygon(Polygon(((200, 0), (300, 0), (300, 100), (200, 100), (200, 0)),
                                                  srid=settings.SRID)))
     self.login()
     params = '?city=09000'
     response = self.client.get(self.model.get_jsonlist_url() + params)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(len(response.json()["map_obj_pk"]), 1)
     params = '?city=09001'
     response = self.client.get(self.model.get_jsonlist_url() + params)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(len(response.json()["map_obj_pk"]), 0)
Exemplo n.º 10
0
 def setUpClass(cls):
     super(ZoningPropertiesMixinTest, cls).setUpClass()
     cls.geom_1_wkt = 'SRID=2154;MULTIPOLYGON(((200000 300000, 900000 300000, 900000 1200000, 200000 1200000, ' \
                      '200000 300000)))'
     cls.geom_2_wkt = 'SRID=2154;MULTIPOLYGON(((900000 300000, 1100000 300000, 1100000 1200000, 900000 1200000, ' \
                      '900000 300000)))'
     cls.city = CityFactory.create(geom=cls.geom_1_wkt)
     cls.district = DistrictFactory.create(geom=cls.geom_1_wkt)
     cls.area = RestrictedAreaFactory.create(geom=cls.geom_1_wkt)