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 10:45:09 +0200 |
| commit | 5d1b3d348c97a128e4eeaae270b4a70cc1998f8b (patch) | |
| tree | f2ca3db8f33ec0088add1918d22174fd7eb63ea9 /archaeological_warehouse/tests.py | |
| parent | d52330d3f042bcd0aa2ad3c10288365922405d01 (diff) | |
| download | Ishtar-5d1b3d348c97a128e4eeaae270b4a70cc1998f8b.tar.bz2 Ishtar-5d1b3d348c97a128e4eeaae270b4a70cc1998f8b.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 371d0d782..20e0e20f0 100644 --- a/archaeological_warehouse/tests.py +++ b/archaeological_warehouse/tests.py @@ -861,10 +861,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() @@ -895,6 +918,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] |
