summaryrefslogtreecommitdiff
path: root/archaeological_operations/tests.py
diff options
context:
space:
mode:
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
commitc909dc8902c4fe51394982146c133eaa85c277a0 (patch)
tree803e5d2cfbf1ba8e4b4dc818027c83d8ce81516b /archaeological_operations/tests.py
parent20a9a040b572911462817806ec38d19e1a6b7e13 (diff)
downloadIshtar-c909dc8902c4fe51394982146c133eaa85c277a0.tar.bz2
Ishtar-c909dc8902c4fe51394982146c133eaa85c277a0.zip
Fix null -> "" errors - fix tests
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r--archaeological_operations/tests.py20
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")