diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-05-07 19:07:07 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-05-07 19:07:07 +0200 |
commit | eb0e6f0a610907c4e3dfcba16eaec8959b504ec8 (patch) | |
tree | 51d7015ab07d09c5b2e31f6cc967703f3a9c1b16 /archaeological_operations/tests.py | |
parent | 301869580379e55128af833b822a556505d5e4da (diff) | |
download | Ishtar-eb0e6f0a610907c4e3dfcba16eaec8959b504ec8.tar.bz2 Ishtar-eb0e6f0a610907c4e3dfcba16eaec8959b504ec8.zip |
Tests: all context record have to be display on ODT export of operation (refs #4078)
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r-- | archaeological_operations/tests.py | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index bc4898b37..657a3aa4c 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -21,6 +21,7 @@ import json import datetime from subprocess import Popen, PIPE import StringIO +import tempfile import zipfile from django.conf import settings @@ -42,7 +43,7 @@ from ishtar_common.models import OrganizationType, Organization, ItemKey, \ DocumentTemplate, PersonType, TargetKeyGroup, JsonDataField, \ JsonDataSection, ImportTarget, FormaterType, CustomForm, ExcludedField from archaeological_files.models import File, FileType -from archaeological_context_records.models import Unit +from archaeological_context_records.models import Unit, ContextRecord from ishtar_common import forms_common from ishtar_common.tests import WizardTest, WizardTestFormData as FormData, \ @@ -938,6 +939,10 @@ class OperationTest(TestCase, OperationInitTest): self.operations += self.create_operation(self.alt_user, self.orgas[0]) self.item = self.operations[0] + for idx in range(15): + ContextRecord.objects.create(label='CR-{}'.format(idx), + operation=self.item) + def testExternalID(self): self.item.code_patriarche = '123456789' self.item.save() @@ -974,7 +979,6 @@ class OperationTest(TestCase, OperationInitTest): self.assertNotIn(PersonType.objects.get(txt_idx='head_scientist'), sra.person_types.all()) - def create_relations(self): rel1 = models.RelationType.objects.create( symmetrical=True, label='Include', txt_idx='include') @@ -1179,7 +1183,7 @@ class OperationTest(TestCase, OperationInitTest): operation = self.operations[0] c = Client() response = c.get(reverse('show-operation', - kwargs={'pk': operation.pk, 'type': 'pdf'})) + kwargs={'pk': operation.pk, 'type': 'odt'})) self.assertEqual(response.status_code, 200) # empty content when not allowed self.assertEqual(response.content, "") @@ -1191,6 +1195,22 @@ class OperationTest(TestCase, OperationInitTest): z = zipfile.ZipFile(f) self.assertIsNone(z.testzip()) + filename = None + for name in z.namelist(): + if name == 'content.xml': + filename = name + break + self.assertIsNotNone(filename) + + tmpdir = tempfile.mkdtemp(prefix='tmp-ishtar-') + imported_file = z.extract(filename, tmpdir) + with open(imported_file) as content_file: + content = content_file.read() + + # check that all context records have been exported #4078 + for idx in range(15): + self.assertIn('CR-{}'.format(idx), content) + def test_json(self): operation = self.operations[0] operation.data = {"groundhog": {"number": 53444, |