diff options
| -rw-r--r-- | archaeological_context_records/tests.py | 13 | ||||
| -rw-r--r-- | archaeological_finds/tests.py | 27 | ||||
| -rw-r--r-- | archaeological_operations/tests.py | 13 | 
3 files changed, 45 insertions, 8 deletions
| diff --git a/archaeological_context_records/tests.py b/archaeological_context_records/tests.py index d856b3785..60fbaa65e 100644 --- a/archaeological_context_records/tests.py +++ b/archaeological_context_records/tests.py @@ -339,6 +339,19 @@ class ContextRecordTest(ContextRecordInit, TestCase):          # reached          self.assertEqual(len(test_obj.find_reached), 0) +    def test_show(self): +        obj = self.context_records[0] +        c = Client() +        response = c.get(reverse('show-contextrecord', kwargs={'pk': obj.pk})) +        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-contextrecord', kwargs={'pk': obj.pk})) +        self.assertEqual(response.status_code, 200) +        self.assertIn('class="sheet"', response.content) +  class ContextRecordSearchTest(ContextRecordInit, TestCase):      fixtures = ImportContextRecordTest.fixtures diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py index 51bb516ea..3aa0f6ea0 100644 --- a/archaeological_finds/tests.py +++ b/archaeological_finds/tests.py @@ -297,11 +297,12 @@ class FindTest(FindInit, TestCase):      def setUp(self):          self.create_finds(force=True) -        password = 'mypassword' -        my_admin = User.objects.create_superuser( -            'myuser', 'myemail@test.com', password) +        self.password = 'mypassword' +        self.username = 'myuser' +        User.objects.create_superuser(self.username, 'myemail@test.com', +                                      self.password)          self.client = Client() -        self.client.login(username=my_admin.username, password=password) +        self.client.login(username=self.username, password=self.password)      def testExternalID(self):          find = self.finds[0] @@ -379,12 +380,22 @@ class FindTest(FindInit, TestCase):          self.assertEqual(find_3b.index, 2)          self.assertEqual(bf_3b.index, 2) -    def testShowFind(self): -        find = self.finds[0] -        response = self.client.get(reverse('display-find', args=[find.pk])) +    def test_show(self): +        obj = self.finds[0] +        response = self.client.get(reverse('display-find', args=[obj.pk]))          self.assertEqual(response.status_code, 200) -        self.assertIn('load_window("/show-find/{}/");'.format(find.pk), +        self.assertIn('load_window("/show-find/{}/");'.format(obj.pk),                        response.content) +        c = Client() +        response = c.get(reverse('show-find', kwargs={'pk': obj.pk})) +        self.assertEqual(response.status_code, 200) +        # empty content when not allowed +        self.assertEqual(response.content, "") + +        c.login(username=self.username, password=self.password) +        response = self.client.get(reverse('show-find', kwargs={'pk': obj.pk})) +        self.assertEqual(response.status_code, 200) +        self.assertIn('class="sheet"', response.content)  class FindSearchTest(FindInit, TestCase): diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index 230a66beb..83672a9f9 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -881,6 +881,19 @@ class OperationTest(TestCase, OperationInitTest):          op_code_idx, lbl = find.cached_label.split(' | ')          self.assertEqual(op_code_idx, 'OA666-00001') +    def test_show(self): +        operation = self.operations[0] +        c = Client() +        response = c.get(reverse('show-operation', kwargs={'pk': operation.pk})) +        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})) +        self.assertEqual(response.status_code, 200) +        self.assertIn('class="sheet"', response.content) +  class OperationSearchTest(TestCase, OperationInitTest):      fixtures = [settings.ROOT_PATH + | 
