summaryrefslogtreecommitdiff
path: root/archaeological_operations/tests.py
diff options
context:
space:
mode:
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
commit02a784588cccb650dd2c91eebfa2853439b7102f (patch)
treecc9c9ebf5cba0a0bf86de276331399fdeab0ea7e /archaeological_operations/tests.py
parent5055826f761d02a1d4d2089fc14f59ad6c056e85 (diff)
downloadIshtar-02a784588cccb650dd2c91eebfa2853439b7102f.tar.bz2
Ishtar-02a784588cccb650dd2c91eebfa2853439b7102f.zip
Tests: specific tests for pdf show
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r--archaeological_operations/tests.py27
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)