summaryrefslogtreecommitdiff
path: root/archaeological_operations/tests.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-02-22 15:45:40 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-02-22 15:45:40 +0100
commit57e4cbc17b54e10757fb752b821cb862067840b7 (patch)
treefd3cd5fd78447db9db5663c3c30c4d4d1379da54 /archaeological_operations/tests.py
parent79942f7242dd38f62dcee79c990070f84718b574 (diff)
downloadIshtar-57e4cbc17b54e10757fb752b821cb862067840b7.tar.bz2
Ishtar-57e4cbc17b54e10757fb752b821cb862067840b7.zip
Fix cache operation update - Parcel associated with context records are not removed!
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r--archaeological_operations/tests.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index 364cc4c8e..9cdeb67e6 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -607,6 +607,9 @@ class OperationInitTest(object):
def create_parcel(self, data={}):
default = {'town': self.get_default_town(),
'section': 'A', 'parcel_number': '1'}
+ if not hasattr(self, 'operations'):
+ self.create_operation()
+ default['operation'] = self.operations[0]
default.update(data)
if not getattr(self, 'parcels', None):
self.parcels = []
@@ -741,6 +744,21 @@ class OperationTest(TestCase, OperationInitTest):
ope2 = create_operation(self.user, values={'year': 0})
self.assertEqual(ope2.operation_code, 2)
+ def test_cache_update(self):
+ self.create_towns()
+ operation = self.operations[0]
+ town, ope_id = operation.cached_label.split(' | ')
+ self.assertIn(town, (u'Intercommunal', u"Multi-town"))
+ self.assertEqual(ope_id, 'OP2010-1')
+ operation = models.Operation.objects.get(pk=operation.pk)
+ operation.year = 2011
+ operation.save()
+ operation.towns.add(self.towns[0])
+ operation = models.Operation.objects.get(pk=operation.pk)
+ town, ope_id = operation.cached_label.split(' | ')
+ self.assertEqual(ope_id, 'OP2011-1')
+ self.assertEqual(town, self.towns[0].name)
+
class OperationSearchTest(TestCase, OperationInitTest):
fixtures = [settings.ROOT_PATH +