diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-10-25 18:47:43 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-10-25 18:47:43 +0200 |
commit | 2cb20872730f20d1a0d73c321f269a754ffb5893 (patch) | |
tree | 997479d14469cda15f0ae5b20c9011eb3a71e6b6 /archaeological_operations/tests.py | |
parent | fcec6f796641431981daaed874a1cda18336996a (diff) | |
parent | 92985883584d6f38313f4050d38eb77f5086896a (diff) | |
download | Ishtar-2cb20872730f20d1a0d73c321f269a754ffb5893.tar.bz2 Ishtar-2cb20872730f20d1a0d73c321f269a754ffb5893.zip |
Merge branch 'develop' into develop-bootstrap
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) |