summaryrefslogtreecommitdiff
path: root/archaeological_context_records/tests.py
diff options
context:
space:
mode:
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
commit898e9e306d1bca2765bf0902cb67cb9d94e03c52 (patch)
tree0b5681eb64aca8616670ac6e03b0b64851b66880 /archaeological_context_records/tests.py
parent0dcab5e02a38a4151bb5a4d44bc351ce1062e072 (diff)
downloadIshtar-898e9e306d1bca2765bf0902cb67cb9d94e03c52.tar.bz2
Ishtar-898e9e306d1bca2765bf0902cb67cb9d94e03c52.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.py33
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