diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-10-25 10:42:07 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-10-25 10:42:07 +0200 | 
| commit | c0f648fac38d4f6dee389a03b279f0f2fd43f012 (patch) | |
| tree | cc9c9ebf5cba0a0bf86de276331399fdeab0ea7e /archaeological_operations/tests.py | |
| parent | 6d2a86a17132ceb61a284110563b2df8c35fce77 (diff) | |
| download | Ishtar-c0f648fac38d4f6dee389a03b279f0f2fd43f012.tar.bz2 Ishtar-c0f648fac38d4f6dee389a03b279f0f2fd43f012.zip | |
Tests: specific tests for pdf show
Diffstat (limited to 'archaeological_operations/tests.py')
| -rw-r--r-- | archaeological_operations/tests.py | 27 | 
1 files changed, 27 insertions, 0 deletions
| diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index 67b89ce11..b75c02cae 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -19,6 +19,7 @@  import json  import datetime +from subprocess import Popen, PIPE  import StringIO  import zipfile @@ -1043,6 +1044,32 @@ class OperationTest(TestCase, OperationInitTest):          self.assertEqual(response.status_code, 200)          self.assertIn('class="sheet"', response.content) +    def test_show_pdf(self): +        operation = self.operations[0] +        c = Client() +        response = c.get(reverse('show-operation', +                                 kwargs={'pk': operation.pk, 'type': 'pdf'})) +        self.assertEqual(response.status_code, 200) +        # empty content when not allowed +        self.assertEqual(response.content, "") +        c.login(username=self.username, password=self.password) +        response = c.get(reverse('show-operation', +                                 kwargs={'pk': operation.pk, 'type': 'pdf'})) +        self.assertEqual(response.status_code, 200) +        f = StringIO.StringIO(response.content) +        filetype = Popen("/usr/bin/file -b --mime -", shell=True, stdout=PIPE, +                         stdin=PIPE).communicate(f.read(1024))[0].strip() +        self.assertTrue(filetype.startswith('application/pdf')) + +    def test_show_odt(self): +        operation = self.operations[0] +        c = Client() +        response = c.get(reverse('show-operation', +                                 kwargs={'pk': operation.pk, 'type': 'pdf'})) +        self.assertEqual(response.status_code, 200) +        # empty content when not allowed +        self.assertEqual(response.content, "") +        c.login(username=self.username, password=self.password)          response = c.get(reverse('show-operation', kwargs={'pk': operation.pk,                                                             'type': 'odt'}))          self.assertEqual(response.status_code, 200) | 
