summaryrefslogtreecommitdiff
path: root/archaeological_operations/tests.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-09-11 14:34:25 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-09-11 14:35:02 +0200
commitb103ce9f92012db9d0bc9164b76705633c3c453a (patch)
treea22f1e8ce124fa48d218d040b7eaafb33915d84b /archaeological_operations/tests.py
parent81dc5e04cd5c71c1fc0f8cd1d4be73620da8e8f0 (diff)
downloadIshtar-b103ce9f92012db9d0bc9164b76705633c3c453a.tar.bz2
Ishtar-b103ce9f92012db9d0bc9164b76705633c3c453a.zip
Serialization - Import/Export: manage put an release of locks
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r--archaeological_operations/tests.py74
1 files changed, 70 insertions, 4 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index 72cecee95..6c20df85a 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -753,6 +753,7 @@ class SerializationTest(GenericSerializationTest, TestCase):
operation = create_operation(self.user,
values={"code_patriarche": "66666"})
ope2 = create_operation(self.user, values={"code_patriarche": "66667"})
+ self.operations = [operation, ope2]
models.RecordRelations.objects.create(
left_record=operation, right_record=ope2,
relation_type=models.RelationType.objects.all()[0]
@@ -815,6 +816,41 @@ class SerializationTest(GenericSerializationTest, TestCase):
)
self.assertEqual(len(rel_json), 0)
+ def reinit_lock(self):
+ for operation in self.operations:
+ operation = models.Operation.objects.get(pk=operation.pk)
+ operation.locked = False
+ operation.lock_user = None
+ operation.save()
+
+ def test_lock(self):
+ self.reinit_lock()
+ self.generic_serialization_test(
+ serializers.operation_serialization, no_test=True,
+ kwargs={"put_locks": False})
+ for operation in self.operations:
+ operation = models.Operation.objects.get(pk=operation.pk)
+ self.assertFalse(operation.locked)
+ self.assertIsNone(operation.lock_user)
+
+ self.reinit_lock()
+ self.generic_serialization_test(
+ serializers.operation_serialization, no_test=True,
+ kwargs={"put_locks": True})
+ for operation in self.operations:
+ operation = models.Operation.objects.get(pk=operation.pk)
+ self.assertTrue(operation.locked)
+ self.assertIsNone(operation.lock_user)
+
+ self.reinit_lock()
+ self.generic_serialization_test(
+ serializers.operation_serialization, no_test=True,
+ kwargs={"put_locks": True, "lock_user": self.user})
+ for operation in self.operations:
+ operation = models.Operation.objects.get(pk=operation.pk)
+ self.assertTrue(operation.locked)
+ self.assertEqual(operation.lock_user, self.user)
+
def test_restore(self):
current_number, zip_filename = self.generic_restore_test_genzip(
serializers.OPERATION_MODEL_LIST,
@@ -822,6 +858,31 @@ class SerializationTest(GenericSerializationTest, TestCase):
self.generic_restore_test(zip_filename, current_number,
serializers.OPERATION_MODEL_LIST)
+ def test_unlock_on_restore(self):
+ current_number, zip_filename = self.generic_restore_test_genzip(
+ serializers.OPERATION_MODEL_LIST,
+ serializers.operation_serialization,
+ kwargs={"put_locks": True, "lock_user": self.user})
+
+ self.generic_restore_test(zip_filename, current_number,
+ serializers.OPERATION_MODEL_LIST,
+ delete_existing=False)
+ for operation in self.operations:
+ operation = models.Operation.objects.get(
+ code_patriarche=operation.code_patriarche)
+ self.assertTrue(operation.locked)
+ self.assertEqual(operation.lock_user, self.user)
+
+ self.generic_restore_test(zip_filename, current_number,
+ serializers.OPERATION_MODEL_LIST,
+ delete_existing=False,
+ release_locks=True)
+ for operation in self.operations:
+ operation = models.Operation.objects.get(
+ code_patriarche=operation.code_patriarche)
+ self.assertFalse(operation.locked)
+ self.assertIsNone(operation.lock_user)
+
def test_historization_on_restore(self):
current_number, zip_filename = self.generic_restore_test_genzip(
serializers.OPERATION_MODEL_LIST,
@@ -1620,18 +1681,23 @@ class LockTest(TestCase, OperationInitTest):
step = 'selec-operation_modification'
response = cls_wiz.wizard_post(
self.client, url, step, {'pk': self.operation.pk})
- self.assertIn("locked for edition", response.content.decode(),
+ msg = str(_("This operation is locked for edition.")
+ ).replace("'", "&#39;")
+ self.assertIn(msg, response.content.decode(),
msg="wizard lock for edition not effective")
def test_qa_lock(self):
url = reverse('operation-qa-bulk-update', args=[self.operation.pk])
response = self.client.get(url)
- self.assertRedirects(response, reverse('qa-not-available'))
+ self.assertRedirects(response, reverse('qa-not-available',
+ args=["locked"]))
def test_sheet_lock(self):
url = reverse('show-operation', kwargs={'pk': self.operation.pk})
response = self.client.get(url)
- self.assertIn('This item has been locked', response.content.decode(),
+ msg = str(_("This item has been locked. Edition is disabled.")
+ ).replace("'", "\'")
+ self.assertIn(msg, response.content.decode(),
msg="lock not displayed on sheet")
@@ -3279,7 +3345,7 @@ class OperationQATest(OperationInitTest, TestCase):
reverse('operation-qa-bulk-update-confirm', args=[pks]),
{'qa_operation_type': operation_type.pk}
)
- self.assertRedirects(response, '/qa-not-available/')
+ self.assertRedirects(response, '/qa-not-available/locked/')
class DocumentQATest(OperationInitTest, TestCase):