Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 625c591122 | |||
| f551763798 |
+15
-10
@@ -113,7 +113,7 @@ class Geometry(BaseResource):
|
||||
objs (list): The list of objects
|
||||
"""
|
||||
objs = []
|
||||
|
||||
stop_searching = False
|
||||
# Some related data sets can be processed rather easily
|
||||
regular_sets = [
|
||||
self.intervention_set,
|
||||
@@ -129,15 +129,20 @@ class Geometry(BaseResource):
|
||||
else:
|
||||
objs += set_objs
|
||||
|
||||
# ... 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
|
||||
comp_objs = self.compensation_set.filter(
|
||||
Q(deleted=None) & Q(intervention__deleted=None)
|
||||
)
|
||||
if limit_to_attrs:
|
||||
objs += comp_objs.values(*limit_to_attrs)
|
||||
else:
|
||||
objs += comp_objs
|
||||
stop_searching = len(objs) > 0
|
||||
if stop_searching:
|
||||
break
|
||||
|
||||
if not stop_searching:
|
||||
# ... 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
|
||||
comp_objs = self.compensation_set.filter(
|
||||
Q(deleted=None) | Q(intervention__deleted=None)
|
||||
)
|
||||
if limit_to_attrs:
|
||||
objs += comp_objs.values(*limit_to_attrs)
|
||||
else:
|
||||
objs += comp_objs
|
||||
return objs
|
||||
|
||||
def get_data_object(self, limit_to_attrs: list = None):
|
||||
|
||||
@@ -85,12 +85,6 @@ class GeometryTestCase(BaseTestCase):
|
||||
)
|
||||
|
||||
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 = [
|
||||
self.intervention,
|
||||
self.compensation,
|
||||
@@ -98,16 +92,13 @@ class GeometryTestCase(BaseTestCase):
|
||||
self.ema,
|
||||
]
|
||||
for obj in objs:
|
||||
obj.geometry = self.geom_1
|
||||
obj.save()
|
||||
if not obj.geometry:
|
||||
obj.geometry = Geometry.objects.create(geom=self.create_dummy_geometry())
|
||||
obj.save()
|
||||
|
||||
num_objs_with_geom += 1
|
||||
geom_objs = self.geom_1.get_data_objects()
|
||||
self.assertEqual(
|
||||
len(geom_objs),
|
||||
num_objs_with_geom
|
||||
)
|
||||
self.assertIn(obj, geom_objs)
|
||||
data_objs = obj.geometry.get_data_objects()
|
||||
self.assertEqual(len(data_objs), 1)
|
||||
self.assertIn(obj, data_objs)
|
||||
|
||||
def test_as_feature_collection(self):
|
||||
geometry = self.geom_1.geom
|
||||
|
||||
Reference in New Issue
Block a user