From 57e4cbc17b54e10757fb752b821cb862067840b7 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 22 Feb 2017 15:45:40 +0100 Subject: Fix cache operation update - Parcel associated with context records are not removed! --- archaeological_operations/tests.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'archaeological_operations/tests.py') 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 + -- cgit v1.2.3