summaryrefslogtreecommitdiff
path: root/archaeological_context_records/tests.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-07-17 13:34:39 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-07-17 13:34:39 +0200
commitb8222c46cee9f850b9f7c85c95500db256598abe (patch)
tree982882e05a2dea5ba0051d084531d6148e060c70 /archaeological_context_records/tests.py
parent76d44b2cc907ca0e99b14f1ca0aa5f83ff261b3f (diff)
downloadIshtar-b8222c46cee9f850b9f7c85c95500db256598abe.tar.bz2
Ishtar-b8222c46cee9f850b9f7c85c95500db256598abe.zip
Context records: short_label -> tiny_label, explicit relation in exports
Diffstat (limited to 'archaeological_context_records/tests.py')
-rw-r--r--archaeological_context_records/tests.py48
1 files changed, 37 insertions, 11 deletions
diff --git a/archaeological_context_records/tests.py b/archaeological_context_records/tests.py
index 2bd144c5e..07da79c8a 100644
--- a/archaeological_context_records/tests.py
+++ b/archaeological_context_records/tests.py
@@ -17,16 +17,17 @@
# See the file COPYING for details.
-"""
-Unit tests
-"""
+import json
from django.conf import settings
from django.core.exceptions import ValidationError
from django.core.files.uploadedfile import SimpleUploadedFile
+from django.core.urlresolvers import reverse
from django.test import TestCase
+from django.test.client import Client
from ishtar_common.models import ImporterType
+from ishtar_common.tests import create_superuser
from archaeological_operations.tests import OperationInitTest, \
ImportOperationTest
from archaeological_context_records import models
@@ -109,15 +110,40 @@ class ContextRecordInit(OperationInitTest):
return self.create_context_record()[0]
+class ContextRecordTest(TestCase, ContextRecordInit):
+ fixtures = ImportContextRecordTest.fixtures
+
+ def setUp(self):
+ self.username, self.password, self.user = create_superuser()
+ self.create_context_record({"label": u"CR 1"})
+ self.create_context_record({"label": u"CR 2"})
+
+ cr_1 = self.context_records[0]
+ cr_2 = self.context_records[1]
+ sym_rel_type = models.RelationType.objects.filter(
+ symmetrical=True).all()[0]
+ models.RecordRelations.objects.create(
+ left_record=cr_1, right_record=cr_2, relation_type=sym_rel_type)
+
+ def testSearchExport(self):
+ "url = reverse()get-contextrecord-full/csv?submited=1&"
+ c = Client()
+ response = c.get(reverse('get-contextrecord'))
+ # no result when no authentification
+ self.assertTrue(not json.loads(response.content))
+ c.login(username=self.username, password=self.password)
+ response = c.get(reverse('get-contextrecord'))
+ self.assertTrue(json.loads(response.content)['total'] == 2)
+ # export
+ response = c.get(reverse('get-contextrecord-full',
+ kwargs={'type': 'csv'}), {'submited': '1'})
+ # 2 lines + header
+ lines = [line for line in response.content.split('\n') if line]
+ self.assertEqual(len(lines), 3)
+
+
class RecordRelationsTest(TestCase, ContextRecordInit):
- fixtures = [settings.ROOT_PATH +
- '../fixtures/initial_data.json',
- settings.ROOT_PATH +
- '../ishtar_common/fixtures/initial_data.json',
- settings.ROOT_PATH +
- '../archaeological_files/fixtures/initial_data.json',
- settings.ROOT_PATH +
- '../archaeological_operations/fixtures/initial_data-fr.json']
+ fixtures = ImportOperationTest.fixtures
model = models.ContextRecord
def setUp(self):