summaryrefslogtreecommitdiff
path: root/archaeological_finds/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_finds/tests.py')
-rw-r--r--archaeological_finds/tests.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py
index acd86727b..3d4d6f1d7 100644
--- a/archaeological_finds/tests.py
+++ b/archaeological_finds/tests.py
@@ -1672,6 +1672,52 @@ class GeomaticTest(FindInit, TestCase):
def setUp(self):
self.create_finds(data_base={"label": u"Find 1"}, force=True)
+ def test_update_container_localisation_on_warehouse_update(self):
+ profile, created = IshtarSiteProfile.objects.get_or_create(
+ slug='default', active=True)
+ profile.mapping = True
+ profile.save()
+ wgs84 = SpatialReferenceSystem.objects.get(srid=4326)
+
+ find = self.finds[0]
+ base_find = find.base_finds.all()[0]
+ self.assertEqual(base_find.x, None)
+
+ operation = Operation.objects.get(
+ pk=base_find.context_record.operation.pk
+ )
+ operation.x, operation.y = 33, 42
+ operation.spatial_reference_system = wgs84
+ operation.save()
+
+ # an update is pending for the linked context record
+ q = ContextRecord.objects.filter(
+ pk=base_find.context_record.pk,
+ need_update=True)
+ self.assertEqual(q.count(), 1)
+
+ # process pending update
+ context_record = q.all()[0]
+ self.assertEqual(context_record.x, None) # update has to be done
+ context_record.skip_history_when_saving = True
+ context_record._no_move = True
+ context_record.save()
+ context_record = ContextRecord.objects.get(pk=context_record.pk)
+ self.assertEqual(context_record.x, 33)
+
+ # then an update is pending for the linked base find
+ q = models.BaseFind.objects.filter(pk=base_find.pk, need_update=True)
+ self.assertEqual(q.count(), 1)
+
+ # process pending update
+ bf = q.all()[0]
+ self.assertEqual(bf.x, None) # update has to be done
+ bf.skip_history_when_saving = True
+ bf._no_move = True
+ bf.save()
+ bf = models.BaseFind.objects.get(pk=bf.pk)
+ self.assertEqual(bf.x, 33)
+
def test_post_save_point(self):
find = self.finds[0]
base_find = find.base_finds.all()[0]