summaryrefslogtreecommitdiff
path: root/archaeological_operations/tests.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2020-05-05 12:39:32 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2020-05-05 12:39:32 +0200
commitb32e7b35ae8c103a6cce466531c80d90dee204e1 (patch)
tree08682b0df3c888226211bc3262539eb79246b6eb /archaeological_operations/tests.py
parent488eb9644093d8dac95f33f0e2d8dcbcd8c4241b (diff)
downloadIshtar-b32e7b35ae8c103a6cce466531c80d90dee204e1.tar.bz2
Ishtar-b32e7b35ae8c103a6cce466531c80d90dee204e1.zip
Tests: test import regex
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r--archaeological_operations/tests.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index 672c06647..af6988568 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -47,7 +47,7 @@ from ishtar_common.models import OrganizationType, Organization, ItemKey, \
DocumentTemplate, PersonType, TargetKeyGroup, JsonDataField, \
JsonDataSection, ImportTarget, FormaterType, CustomForm, ExcludedField, \
UserProfile, ProfileType, Area, CustomFormJsonField, get_current_profile, \
- Document, ValueFormater
+ Document, ValueFormater, Regexp
from archaeological_files.models import File, FileType
from archaeological_context_records.models import Unit, ContextRecord
@@ -586,6 +586,28 @@ class ImportOperationTest(ImportTest, TestCase):
self.assertEqual(ope2.data, {u'autre_refs': {u'arbitraire': 456},
u"autre": 333})
+ def test_regexp(self):
+ importer, form = self.init_ope_import("operations-with-json-fields.csv")
+ r, __ = Regexp.objects.get_or_create(
+ name="Code INSEE",
+ regexp='([0-9]{0,1}[0-9A-B]) *([0-9]{3})'
+ )
+ col = ImporterColumn.objects.create(
+ importer_type=importer, col_number=13, regexp_pre_filter=r)
+ formater_type = FormaterType.objects.get(
+ formater_type='UnicodeFormater', options="")
+ ImportTarget.objects.create(
+ column=col, target='data__code_insee',
+ formater_type=formater_type)
+ impt = form.save(self.ishtar_user)
+ impt.initialize()
+ self.init_ope_targetkey(imp=impt)
+ impt.importation()
+ ope1 = models.Operation.objects.get(code_patriarche='4200')
+ self.assertEqual(ope1.data, {"code_insee": "45123"})
+ ope2 = models.Operation.objects.get(code_patriarche='4201')
+ self.assertEqual(ope2.data, {"code_insee": "6456"})
+
class ImportDocumentTest(ImportTest, TestCase):
fixtures = OPERATION_TOWNS_FIXTURES