diff options
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 |
commit | b564d3d2d32782ca439f9d721d01b0fe6cff25a3 (patch) | |
tree | fd3cd5fd78447db9db5663c3c30c4d4d1379da54 /archaeological_operations/tests.py | |
parent | 2b059ee6ed6e90c63ab8f04d3709800d4d365227 (diff) | |
download | Ishtar-b564d3d2d32782ca439f9d721d01b0fe6cff25a3.tar.bz2 Ishtar-b564d3d2d32782ca439f9d721d01b0fe6cff25a3.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.py | 18 |
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 + |