summaryrefslogtreecommitdiff
path: root/archaeological_operations/tests.py
diff options
context:
space:
mode:
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
commitd71ab9b6f0efc1ec27cc4dcafdad1f3119a2566a (patch)
tree997479d14469cda15f0ae5b20c9011eb3a71e6b6 /archaeological_operations/tests.py
parent95a7082eb3284818d6e0711c07b433a28c31dca7 (diff)
parent7446f5449fe9638c9e4ee97cdeed9dbb748d2b14 (diff)
downloadIshtar-d71ab9b6f0efc1ec27cc4dcafdad1f3119a2566a.tar.bz2
Ishtar-d71ab9b6f0efc1ec27cc4dcafdad1f3119a2566a.zip
Merge branch 'develop' into develop-bootstrap
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)