diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-10-22 15:51:43 +0200 |
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-10-24 18:37:06 +0200 |
| commit | 0393dfd0d4ac8d7ecf1f3443fd0f26c055765b42 (patch) | |
| tree | 2f88ebcd5b4b89508db617d0eaa91c4da32fc50d /archaeological_warehouse/tests.py | |
| parent | c42fba6c77d189df076164e3d159de59b76d7727 (diff) | |
| download | Ishtar-0393dfd0d4ac8d7ecf1f3443fd0f26c055765b42.tar.bz2 Ishtar-0393dfd0d4ac8d7ecf1f3443fd0f26c055765b42.zip | |
🐛 fix regenerate cached label of childs on container move (refs #6480)
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 1a2b42053..0b677475d 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] |
