* updates tests
* enhances workflow of geometry conflict fetching
This commit is contained in:
2026-06-25 08:55:50 +02:00
parent f551763798
commit 625c591122
2 changed files with 9 additions and 19 deletions
+3 -4
View File
@@ -113,7 +113,7 @@ class Geometry(BaseResource):
objs (list): The list of objects objs (list): The list of objects
""" """
objs = [] objs = []
stop_searching = False
# Some related data sets can be processed rather easily # Some related data sets can be processed rather easily
regular_sets = [ regular_sets = [
self.intervention_set, self.intervention_set,
@@ -129,12 +129,11 @@ class Geometry(BaseResource):
else: else:
objs += set_objs objs += set_objs
stop_searching = objs is not None stop_searching = len(objs) > 0
if stop_searching: if stop_searching:
break break
search_for_comps = not objs if not stop_searching:
if search_for_comps:
# ... but we need a special treatment for compensations, since they can be deleted directly OR inherit their # ... but we need a special treatment for compensations, since they can be deleted directly OR inherit their
# de-facto-deleted status from their deleted parent intervention # de-facto-deleted status from their deleted parent intervention
comp_objs = self.compensation_set.filter( comp_objs = self.compensation_set.filter(
+6 -15
View File
@@ -85,12 +85,6 @@ class GeometryTestCase(BaseTestCase):
) )
def test_get_data_objects(self): def test_get_data_objects(self):
num_objs_with_geom = 0
self.assertEqual(
len(self.geom_1.get_data_objects()),
num_objs_with_geom
)
objs = [ objs = [
self.intervention, self.intervention,
self.compensation, self.compensation,
@@ -98,16 +92,13 @@ class GeometryTestCase(BaseTestCase):
self.ema, self.ema,
] ]
for obj in objs: for obj in objs:
obj.geometry = self.geom_1 if not obj.geometry:
obj.save() obj.geometry = Geometry.objects.create(geom=self.create_dummy_geometry())
obj.save()
num_objs_with_geom += 1 data_objs = obj.geometry.get_data_objects()
geom_objs = self.geom_1.get_data_objects() self.assertEqual(len(data_objs), 1)
self.assertEqual( self.assertIn(obj, data_objs)
len(geom_objs),
num_objs_with_geom
)
self.assertIn(obj, geom_objs)
def test_as_feature_collection(self): def test_as_feature_collection(self):
geometry = self.geom_1.geom geometry = self.geom_1.geom