diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-10-19 16:29:55 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-10-19 16:29:55 +0200 | 
| commit | 2d783c053e96120139efffa5f8280f64a8b44fe3 (patch) | |
| tree | 3688ff4d93476aca0d1568a2670f564b5ddaa5f0 /archaeological_operations/tests.py | |
| parent | baa4f718cf64d8da4185910e7bc5e600705f9d24 (diff) | |
| download | Ishtar-2d783c053e96120139efffa5f8280f64a8b44fe3.tar.bz2 Ishtar-2d783c053e96120139efffa5f8280f64a8b44fe3.zip | |
Json fields: manage imports (refs #3077)
Diffstat (limited to 'archaeological_operations/tests.py')
| -rw-r--r-- | archaeological_operations/tests.py | 21 | 
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 | 
