summaryrefslogtreecommitdiff
path: root/archaeological_finds/tests.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2024-08-29 17:22:48 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2024-09-05 16:09:19 +0200
commit1720a9a24b4d53cd4d5981f1b847bd3642fa6fae (patch)
treef3fa122ebc9f98091a9511abff79088de71c299d /archaeological_finds/tests.py
parentf38be838170e93c60c7f7cd1f1d0f7c0fd0cf2fa (diff)
downloadIshtar-1720a9a24b4d53cd4d5981f1b847bd3642fa6fae.tar.bz2
Ishtar-1720a9a24b4d53cd4d5981f1b847bd3642fa6fae.zip
✨ manage find localization history
Diffstat (limited to 'archaeological_finds/tests.py')
-rw-r--r--archaeological_finds/tests.py49
1 files changed, 48 insertions, 1 deletions
diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py
index 346aa0b1e..3c38583ae 100644
--- a/archaeological_finds/tests.py
+++ b/archaeological_finds/tests.py
@@ -2204,7 +2204,20 @@ class FindQATest(FindInit, TestCase):
)
packaging = models.TreatmentType.objects.get(txt_idx="packaging")
packaging.change_reference_location = True
+ packaging.change_current_location = False
packaging.save()
+ packaging2, __ = models.TreatmentType.objects.get_or_create(
+ txt_idx="packaging-2", defaults={"virtual": False}
+ )
+ packaging2.change_reference_location = True
+ packaging2.change_current_location = True
+ packaging2.save()
+ packaging3, __ = models.TreatmentType.objects.get_or_create(
+ txt_idx="packaging-3", defaults={"virtual": False}
+ )
+ packaging3.change_reference_location = False
+ packaging3.change_current_location = True
+ packaging3.save()
data_check_lst = [
(
@@ -2242,9 +2255,32 @@ class FindQATest(FindInit, TestCase):
{"container_ref": container2, "container": None},
1,
),
+ (
+ {
+ "qa-packaging-container": container2.pk,
+ "qa-packaging-container_to_change": "current-and-reference",
+ "qa-packaging-create_treatment": True,
+ "qa-packaging-year": 2019,
+ "qa-packaging-treatment_type": packaging2.pk,
+ },
+ {"container_ref": container2, "container": container2},
+ 1,
+ ),
+ (
+ {
+ "qa-packaging-container": container2.pk,
+ "qa-packaging-container_to_change": "current",
+ "qa-packaging-create_treatment": True,
+ "qa-packaging-year": 2019,
+ "qa-packaging-treatment_type": packaging3.pk,
+ },
+ {"container_ref": None, "container": container2},
+ 1,
+ ),
]
- for data, check, nb_treat in data_check_lst:
+ for idx, lst in enumerate(data_check_lst):
+ data, check, nb_treat = lst
# reinit
find_0.container, find_0.container_ref = None, None
find_0.skip_history_when_saving = True
@@ -2266,6 +2302,17 @@ class FindQATest(FindInit, TestCase):
final_nb_treat = models.Treatment.objects.count()
self.assertEqual(init_nb_treat + nb_treat, final_nb_treat)
+ if not final_nb_treat:
+ self.assertEqual(models.FindTreatment.objects.filter(find=find_0).count(), 0)
+ continue
+
+ treatment = models.Treatment.objects.order_by("-pk")[0]
+ q = models.FindTreatment.objects.filter(treatment=treatment)
+ self.assertEqual(q.filter(find=find_0).count(), 1)
+ ft = q.all()[0]
+ self.assertTrue(ft.full_location)
+ self.assertTrue(ft.location_type)
+
class FindHistoryTest(FindInit, TestCase):
fixtures = FIND_FIXTURES