summaryrefslogtreecommitdiff
path: root/archaeological_operations/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r--archaeological_operations/tests.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index 9779ad424..51dd1c346 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -56,6 +56,7 @@ from ishtar_common.tests import WizardTest, WizardTestFormData as FormData, \
create_superuser, create_user, TestCase, OPERATION_FIXTURES, \
AutocompleteTestBase, AcItem, OPERATION_TOWNS_FIXTURES, FILE_FIXTURES, \
COMMON_FIXTURES, GenericSerializationTest, WAREHOUSE_FIXTURES
+from ishtar_common.serializers import restore_serialized
class FileInit(object):
@@ -821,6 +822,34 @@ class SerializationTest(GenericSerializationTest, TestCase):
self.generic_restore_test(zip_filename, current_number,
serializers.OPERATION_MODEL_LIST)
+ def test_historization_on_restore(self):
+ current_number, zip_filename = self.generic_restore_test_genzip(
+ serializers.OPERATION_MODEL_LIST,
+ serializers.operation_serialization)
+
+ operation = models.Operation.objects.get(code_patriarche="66666")
+ version_nb = operation.history.count()
+
+ restore_serialized(zip_filename, delete_existing=False)
+ operation = models.Operation.objects.get(code_patriarche="66666")
+ self.assertEqual(operation.history_creator, self.user)
+ self.assertEqual(operation.history_modifier, self.user)
+ # no new version
+ self.assertEqual(operation.history.count(), version_nb)
+
+ __, __, new_user = create_user()
+ restore_serialized(zip_filename, delete_existing=False, user=new_user)
+ operation = models.Operation.objects.get(code_patriarche="66666")
+ self.assertEqual(operation.history_creator, self.user)
+ self.assertEqual(operation.history_modifier, new_user)
+ self.assertEqual(operation.history.count(), version_nb + 1)
+
+ restore_serialized(zip_filename, delete_existing=True, user=new_user)
+ operation = models.Operation.objects.get(code_patriarche="66666")
+ self.assertEqual(operation.history_creator, new_user)
+ self.assertEqual(operation.history_modifier, new_user)
+ self.assertEqual(operation.history.count(), 1)
+
class ParcelTest(ImportTest, TestCase):
fixtures = OPERATION_TOWNS_FIXTURES