diff options
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r-- | archaeological_operations/tests.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index d2cbb707e..bbf736112 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -1179,8 +1179,12 @@ def create_operation(user, orga=None, values=None): dct.update(values) if orga: dct['operator'] = orga - operation = models.Operation.objects.create(**dct) - return operation + if 'code_patriarche' not in dct: + idx = 1 + while models.Operation.objects.filter(code_patriarche=str(idx)).count(): + idx += 1 + dct["code_patriarche"] = str(idx) + return models.Operation.objects.create(**dct) class OperationInitTest(object): @@ -1328,24 +1332,28 @@ class OperationTest(TestCase, OperationInitTest): def test_complete_identifier(self): profile = get_current_profile() profile.operation_complete_identifier = \ - "{code_patriarche}-{town__numero_insee}" + "{code_patriarche}-{towns__numero_insee}" profile.save() + self.item = models.Operation.objects.get(pk=self.item.pk) + t = Town.objects.create(numero_insee="12345", name="OK town") + self.item.towns.add(t) + self.item = models.Operation.objects.get(pk=self.item.pk) self.item.code_patriarche = '123456789' self.item.year = 2020 self.item.save() self.item = models.Operation.objects.get(pk=self.item.pk) self.assertEqual(self.item.complete_identifier, '{}-{}'.format(self.item.code_patriarche, - self.item.town.numero_insee)) + t.numero_insee)) profile.operation_complete_identifier = \ - "{year}-{town__numero_insee}" + "{year}-{towns__numero_insee}" profile.save() self.item.save() self.item = models.Operation.objects.get(pk=self.item.pk) self.assertEqual(self.item.complete_identifier, '{}-{}'.format(self.item.year, - self.item.town.numero_insee)) + t.numero_insee)) def test_associated(self): scientist = Person.objects.create(name="C-3PO") |