diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-12-15 18:37:26 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-02-28 12:15:22 +0100 |
commit | 173db6ad38f8286db3953e5965af37b0f2d953c4 (patch) | |
tree | 803e5d2cfbf1ba8e4b4dc818027c83d8ce81516b /archaeological_operations/tests.py | |
parent | 99b583ae953b71840f986f26f827f55d445594a4 (diff) | |
download | Ishtar-173db6ad38f8286db3953e5965af37b0f2d953c4.tar.bz2 Ishtar-173db6ad38f8286db3953e5965af37b0f2d953c4.zip |
Fix null -> "" errors - fix tests
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") |