diff options
Diffstat (limited to 'archaeological_operations/tests.py')
| -rw-r--r-- | archaeological_operations/tests.py | 36 | 
1 files changed, 36 insertions, 0 deletions
| diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index 01418141d..14577e119 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -2547,3 +2547,39 @@ class SiteTest(TestCase, OperationInitTest):          search = {'search_vector': 'reference="reference*"'}          response = c.get(reverse('get-site'), search)          self.assertEqual(json.loads(response.content)['recordsTotal'], 1) + + +class GenerateQRCode(OperationInitTest, TestCase): +    fixtures = FILE_FIXTURES + +    def setUp(self): +        self.username, self.password, self.user = create_superuser() +        self.operation = self.create_operation(self.user)[0] + +    def test_display(self): +        if self.operation.qrcode.name: +            self.operation.qrcode = None +            self.operation.save() +        operation = models.Operation.objects.get(pk=self.operation.pk) +        self.assertIn(operation.qrcode.name, ["", None]) +        c = Client() +        url = reverse('qrcode-item', args=[ +            'archaeological-operations', 'operation', operation.pk]) +        response = c.get(url) +        self.assertEqual(response.status_code, 302) +        c.login(username=self.username, password=self.password) +        response = c.get(url) +        self.assertEqual(response.status_code, 200) +        self.assertEqual(response['Content-Type'], "image/png") +        operation = models.Operation.objects.get(pk=self.operation.pk) +        self.assertIsNotNone(operation.qrcode.name) + +    def test_generation(self): +        self.assertIsNone(self.operation.qrcode.name) +        self.operation.generate_qrcode() +        self.assertIsNotNone(self.operation.qrcode.name) +        self.assertTrue( +            self.operation.qrcode.name.startswith( +                "operation/2010/OP2010-1/qrcode" +            ) +        ) | 
