diff options
Diffstat (limited to 'ishtar_common/tests.py')
-rw-r--r-- | ishtar_common/tests.py | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index 4156f9f0f..cfd3544dd 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -3323,6 +3323,12 @@ class GeoVectorTest(TestCase): # accounts self.username, self.password, self.user = create_superuser() + profile, created = models.IshtarSiteProfile.objects.get_or_create( + slug="default", active=True + ) + profile.mapping = True + profile.save() + # operation, context record, find operation_type = models.OperationType.objects.get(txt_idx="arch_diagnostic") data = { @@ -3479,7 +3485,51 @@ class GeoVectorTest(TestCase): self.assertEqual(self.base_find.main_geodata, geo_vector_find) self.assertEqual(self.base_find.geodata.count(), 1) - # test town add + def test_geotown_add(self): + town = models.Town.objects.create(name="Town") + self.assertIsNone(town.main_geodata) + self.assertEqual(town.geodata.count(), 0) + + data_type = models.GeoDataType.objects.get( + txt_idx="town-limit", + ) + town_ct = ContentType.objects.get( + model="town", + app_label="ishtar_common", + ).pk + multi_polygon = MultiPolygon( + Polygon(((1, 1), (5, 1), (5, 5), (1, 1))), + Polygon(((2, 2), (2, 3), (3, 3), (2, 2))), + srid=4326 + ) + geo_vector_town = models.GeoVectorData.objects.create( + source_content_type_id=town_ct, + source_id=town.id, + name="Test town geo", + origin=self.origin, + data_type=data_type, + provider=self.provider, + comment="This is a comment.", + multi_polygon=multi_polygon + ) + town.geodata.add(geo_vector_town) + town = models.Town.objects.get(pk=town.pk) + self.assertEqual(town.geodata.count(), 1) + self.assertEqual(town.main_geodata, geo_vector_town) + + self.operation.towns.add(town) + self._reinit_objects() + # save need to be forced... keep it? + self.operation.save() + + self._reinit_objects() + self.assertEqual(self.operation.geodata.count(), 1) + self.assertEqual(self.operation.main_geodata, geo_vector_town) + self.assertEqual(self.context_record.geodata.count(), 1) + self.assertEqual(self.context_record.main_geodata, geo_vector_town) + self.assertEqual(self.base_find.geodata.count(), 1) + self.assertEqual(self.base_find.main_geodata, geo_vector_town) + # test town remove |