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.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index 1b64f581d..9d5b9c616 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -17,9 +17,6 @@
# See the file COPYING for details.
-"""
-Unit tests
-"""
import json
import datetime
@@ -57,11 +54,11 @@ class ImportTest(object):
tg.is_set = True
tg.save()
- def init_ope_import(self):
+ def init_ope_import(self, filename='MCC-operations-example.csv'):
mcc_operation = ImporterType.objects.get(name=u"MCC - Opérations")
mcc_operation_file = open(
settings.ROOT_PATH +
- '../archaeological_operations/tests/MCC-operations-example.csv',
+ '../archaeological_operations/tests/' + filename,
'rb')
file_dict = {'imported_file': SimpleUploadedFile(
mcc_operation_file.name, mcc_operation_file.read())}
@@ -209,6 +206,9 @@ class ImportOperationTest(ImportTest, TestCase):
self.assertEqual(last_ope,
models.Operation.objects.order_by('-pk').all()[0])
+ def test_import_bad_encoding(self):
+ self.init_ope_import('MCC-operations-example-bad-encoding.csv')
+
def test_keys_limitation(self):
# each key association is associated to the import
init_ope_number = models.Operation.objects.count()
@@ -242,7 +242,10 @@ class ImportOperationTest(ImportTest, TestCase):
self.init_ope_targetkey(imp=impt)
impt.importation()
self.assertEqual(len(impt.errors), 2)
- self.assertIn("Importer configuration error", impt.errors[0]['error'])
+ self.assertTrue(
+ "Importer configuration error" in impt.errors[0]['error'] or
+ "Erreur de configuration de l\'importeur" in impt.errors[0]['error']
+ )
def test_model_limitation(self):
importer, form = self.init_ope_import()
@@ -662,7 +665,6 @@ class OperationInitTest(object):
self.operations.pop(0)
return self.create_operation()[-1]
-
def tearDown(self):
# cleanup for further test
if hasattr(self, 'user'):
@@ -1192,7 +1194,7 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase):
def post_first_wizard(test_object, final_step_response):
test_object.assertEqual(models.Operation.objects.count(),
- test_object.operation_number)
+ test_object.operation_number)
operation = models.Operation.objects.get(
pk=test_object.operations[0].pk)
test_object.assertEqual(operation.operation_type.pk, 2)