diff options
Diffstat (limited to 'archaeological_warehouse/tests.py')
| -rw-r--r-- | archaeological_warehouse/tests.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/archaeological_warehouse/tests.py b/archaeological_warehouse/tests.py index 4290e2c42..382efb769 100644 --- a/archaeological_warehouse/tests.py +++ b/archaeological_warehouse/tests.py @@ -880,10 +880,33 @@ class ContainerTest(FindInit, TestCase): def test_change_location(self): find = self.create_finds()[0][0] find = Find.objects.get(pk=find.pk) + + main_container_1 = models.Container.objects.create( + reference="Test - main container", + responsible=self.main_warehouse, + location=self.main_warehouse, + container_type=models.ContainerType.objects.all()[1], + ) + main_container_2 = models.Container.objects.create( + reference="Test - main container 2", + responsible=self.main_warehouse, + location=self.main_warehouse, + container_type=models.ContainerType.objects.all()[1], + ) + top_container_1 = models.Container.objects.create( + reference="Test - top container", + responsible=self.main_warehouse, + location=self.main_warehouse, + container_type=models.ContainerType.objects.all()[1], + parent=main_container_1 + ) + + # simple localisation container = models.Container.objects.create( reference="Test", responsible=self.main_warehouse, location=self.main_warehouse, + parent=top_container_1, container_type=models.ContainerType.objects.all()[0], ) container.save() @@ -914,6 +937,26 @@ class ContainerTest(FindInit, TestCase): division__warehouse=self.main_warehouse ).count() ) + + # test cascade update + top_container_1.parent = main_container_2 + top_container_1.save() + container = models.Container.objects.get(pk=container.pk) + container_2 = models.Container.objects.get(pk=container_2.pk) + find = Find.objects.get(pk=find.pk) + self.assertTrue( + find.container_fisrt_full_location.startswith( + main_container_2.generate_full_location() + ) + ) + self.assertTrue( + find.container_ref_fisrt_full_location.startswith( + main_container_2.generate_full_location() + ) + ) + self.assertEqual(find.container_fisrt_full_location, container.generate_full_location()) + self.assertEqual(find.container_ref_fisrt_full_location, container_2.generate_full_location()) + # changing location remove irrelevant localisation other_warehouse = models.Warehouse.objects.create( name="Other", warehouse_type=models.WarehouseType.objects.all()[0] |
