diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-03-07 17:34:18 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-03-07 17:34:18 +0100 |
commit | 9d8ef84d18eddcadf0398a42c3606333d0c89d6a (patch) | |
tree | 0b5681eb64aca8616670ac6e03b0b64851b66880 /archaeological_context_records/tests.py | |
parent | 70bf74767fccbe6cbdf4592759b31ddd5bb7d9c3 (diff) | |
download | Ishtar-9d8ef84d18eddcadf0398a42c3606333d0c89d6a.tar.bz2 Ishtar-9d8ef84d18eddcadf0398a42c3606333d0c89d6a.zip |
Exports: specific configuration to manage ambiguous column (refs #3446)
Diffstat (limited to 'archaeological_context_records/tests.py')
-rw-r--r-- | archaeological_context_records/tests.py | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/archaeological_context_records/tests.py b/archaeological_context_records/tests.py index 2e1355572..c9795fce7 100644 --- a/archaeological_context_records/tests.py +++ b/archaeological_context_records/tests.py @@ -17,7 +17,9 @@ # See the file COPYING for details. +import csv import json +from StringIO import StringIO from django.conf import settings from django.core.exceptions import ValidationError, ImproperlyConfigured @@ -26,6 +28,7 @@ from django.test.client import Client from ishtar_common.models import IshtarSiteProfile, ImporterModel from ishtar_common.tests import create_superuser, TestCase + from archaeological_operations.tests import OperationInitTest, \ ImportTest, ImportOperationTest from archaeological_operations import models as models_ope @@ -183,6 +186,35 @@ class ContextRecordInit(OperationInitTest): super(ContextRecordInit, self).tearDown() +class ExportTest(ContextRecordInit, TestCase): + fixtures = ImportContextRecordTest.fixtures + + def setUp(self): + self.username, self.password, self.user = create_superuser() + + def test_ishtar_export_ue(self): + ope = self.create_operation()[0] + ope.code_patriarche = "45000" + ope.save() + cr = self.create_context_record(data={"label": u"CR 1"})[0] + c = Client() + url = reverse('get-by-importer', + kwargs={'slug': 'ishtar-context-record', + 'type': 'csv'}) + response = c.get(url) + # no result when no authentication + self.assertTrue(not response.content) + c.login(username=self.username, password=self.password) + response = c.get(url) + rows = list(csv.reader(StringIO(response.content))) + # one header + one context record + self.assertEqual(len(rows), 2) + row_cr = rows[1] + self.assertEqual(row_cr[0], '45000') + self.assertEqual(row_cr[1], '12345') + self.assertEqual(row_cr[2], 'A1') + + class ContextRecordTest(ContextRecordInit, TestCase): fixtures = ImportContextRecordTest.fixtures @@ -254,7 +286,6 @@ class ContextRecordTest(ContextRecordInit, TestCase): self.assertEqual(ope_id, 'OP2017-1') - class ContextRecordSearchTest(ContextRecordInit, TestCase): fixtures = ImportContextRecordTest.fixtures |