From 03cb63b9b6c5d0d2a63088528da24f187457f4a1 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 20 Sep 2017 13:45:27 +0200 Subject: Fix external id generation for finds --- archaeological_finds/tests.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'archaeological_finds/tests.py') diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py index 3e89273a0..05eef2c96 100644 --- a/archaeological_finds/tests.py +++ b/archaeological_finds/tests.py @@ -29,7 +29,7 @@ from ishtar_common.models import ImporterType, IshtarUser, ImporterColumn,\ FormaterType, ImportTarget, IshtarSiteProfile from ishtar_common.models import Person, get_current_profile -from archaeological_context_records.models import Period, Dating +from archaeological_context_records.models import Period, Dating, ContextRecord from archaeological_finds import models, views from archaeological_warehouse.models import Warehouse, WarehouseType @@ -356,6 +356,30 @@ class FindTest(FindInit, TestCase): u"{}-{}".format( base_find.context_record.external_id, base_find.label)) + base_find.label = "New label" + base_find.save() + base_find = models.BaseFind.objects.get(pk=base_find.pk) + self.assertEqual( + base_find.external_id, + u"{}-{}".format( + base_find.context_record.external_id, + "New label")) + cr = ContextRecord.objects.get(pk=base_find.context_record.pk) + cr.label = "new-label-too" + cr.save() + base_find = models.BaseFind.objects.get(pk=base_find.pk) + find = models.Find.objects.get(pk=find.pk) + cr = ContextRecord.objects.get(pk=cr.pk) + self.assertIn("new-label-too", find.external_id) + self.assertIn("new-label-too", base_find.external_id) + + cr.operation.code_patriarche = "PAT" + cr.operation.save() + base_find = models.BaseFind.objects.get(pk=base_find.pk) + find = models.Find.objects.get(pk=find.pk) + cr = ContextRecord.objects.get(pk=cr.pk) + self.assertIn("PAT", find.external_id) + self.assertIn("PAT", base_find.external_id) def testIndex(self): profile = get_current_profile() -- cgit v1.2.3