diff options
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 |
commit | e87be285da2557f3a684418c9f91c9dc22139fda (patch) | |
tree | a22f1e8ce124fa48d218d040b7eaafb33915d84b /archaeological_operations/tests.py | |
parent | 0a18b35422fd85f9cbb39796275bc90065c80689 (diff) | |
download | Ishtar-e87be285da2557f3a684418c9f91c9dc22139fda.tar.bz2 Ishtar-e87be285da2557f3a684418c9f91c9dc22139fda.zip |
Serialization - Import/Export: manage put an release of locks
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r-- | archaeological_operations/tests.py | 74 |
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("'", "'") + 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): |