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.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index ab0876aef..67b89ce11 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -38,7 +38,8 @@ from archaeological_operations import views
from ishtar_common.models import OrganizationType, Organization, ItemKey, \
ImporterType, IshtarUser, TargetKey, ImporterModel, IshtarSiteProfile, \
Town, ImporterColumn, Person, Author, SourceType, AuthorType, \
- DocumentTemplate, PersonType, TargetKeyGroup, JsonDataField, JsonDataSection
+ DocumentTemplate, PersonType, TargetKeyGroup, JsonDataField, \
+ JsonDataSection, ImportTarget, FormaterType
from archaeological_files.models import File, FileType
from archaeological_context_records.models import Unit
@@ -454,6 +455,24 @@ class ImportOperationTest(ImportTest, TestCase):
impt.delete()
self.assertEqual(parcel_count - 3, models.Parcel.objects.count())
+ def test_json_fields(self):
+ importer, form = self.init_ope_import("operations-with-json-fields.csv")
+ col = ImporterColumn.objects.create(importer_type=importer,
+ col_number=11)
+ formater_type = FormaterType.objects.get(
+ formater_type='IntegerFormater')
+ ImportTarget.objects.create(
+ column=col, target='data__autre_refs__arbitraire',
+ 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, {u'autre_refs': {u'arbitraire': 789}})
+ ope2 = models.Operation.objects.get(code_patriarche='4201')
+ self.assertEqual(ope2.data, {u'autre_refs': {u'arbitraire': 456}})
+
class ParcelTest(ImportTest, TestCase):
fixtures = OPERATION_TOWNS_FIXTURES