diff options
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) |