diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-06-28 14:50:12 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-06-28 14:50:12 +0200 | 
| commit | 3eee5bac1748181d41d7abc32da1570a1fce6645 (patch) | |
| tree | 2f2f39dfb5c185d8e8857b2f87bbeff6065bb321 /archaeological_finds/tests.py | |
| parent | f1366d27a7ccfcd2745aa0854f217941f6b2198c (diff) | |
| download | Ishtar-3eee5bac1748181d41d7abc32da1570a1fce6645.tar.bz2 Ishtar-3eee5bac1748181d41d7abc32da1570a1fce6645.zip  | |
Better management of cascade updates
Diffstat (limited to 'archaeological_finds/tests.py')
| -rw-r--r-- | archaeological_finds/tests.py | 46 | 
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]  | 
