#50 Overlaying geometries Tests
* adds test for geometry conflicts * refactors rechecking of existing conflicts to avoid recursion in certain cases * adds/updates translations
This commit is contained in:
49
konova/tests/test_geometries.py
Normal file
49
konova/tests/test_geometries.py
Normal file
@@ -0,0 +1,49 @@
|
||||
"""
|
||||
Author: Michel Peltriaux
|
||||
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
|
||||
Contact: michel.peltriaux@sgdnord.rlp.de
|
||||
Created on: 15.12.21
|
||||
|
||||
"""
|
||||
from django.contrib.gis.db.models.functions import Translate
|
||||
|
||||
from konova.models import Geometry, GeometryConflict
|
||||
from konova.tests.test_views import BaseTestCase
|
||||
from user.models import UserActionLogEntry
|
||||
|
||||
|
||||
class GeometryTestCase(BaseTestCase):
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
super().setUpTestData()
|
||||
geom = cls.create_dummy_geometry()
|
||||
action = UserActionLogEntry.get_created_action(cls.superuser)
|
||||
cls.geom_1 = Geometry.objects.create(
|
||||
geom=geom,
|
||||
created=action,
|
||||
)
|
||||
cls.geom_2 = Geometry.objects.create(
|
||||
geom=geom,
|
||||
created=action,
|
||||
)
|
||||
|
||||
def test_geometry_conflict(self):
|
||||
""" Tests whether a geometry conflict will be present in case of identical/overlaying geometries and
|
||||
if the conflict will be resolved if one geometry is edited.
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
self.geom_1.check_for_conflicts()
|
||||
conflict = GeometryConflict.objects.all().first()
|
||||
self.assertEqual(conflict.conflicting_geometry, self.geom_2)
|
||||
self.assertEqual(conflict.affected_geometry, self.geom_1)
|
||||
|
||||
# Move geom_2 somewhere else, expect the conflict to be resolved
|
||||
Geometry.objects.filter(id=self.geom_2.id).update(
|
||||
geom=Translate('geom', 100000, 100000)
|
||||
)
|
||||
self.geom_2.refresh_from_db()
|
||||
self.geom_1.check_for_conflicts()
|
||||
num_conflict = GeometryConflict.objects.all().count()
|
||||
self.assertEqual(0, num_conflict)
|
||||
Reference in New Issue
Block a user