diff options
| author | Tim Graham <timograham@gmail.com> | 2016-09-27 15:37:32 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-09-27 18:54:35 -0400 |
| commit | 231743414710c60090728e86f33d81cbc43df1d1 (patch) | |
| tree | 20e0a10acbbc3d98a6d8c8cbe7b544d3fbac6a2d /tests/admin_docs/test_middleware.py | |
| parent | 62543260dd58309902fa73f0984e245fd6c6da2a (diff) | |
Split admin_docs tests into separate files.
Diffstat (limited to 'tests/admin_docs/test_middleware.py')
| -rw-r--r-- | tests/admin_docs/test_middleware.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/admin_docs/test_middleware.py b/tests/admin_docs/test_middleware.py new file mode 100644 index 0000000000..426c78d58f --- /dev/null +++ b/tests/admin_docs/test_middleware.py @@ -0,0 +1,44 @@ +from __future__ import unicode_literals + +from django.contrib.auth.models import User + +from .tests import AdminDocsTestCase, TestDataMixin + + +class XViewMiddlewareTest(TestDataMixin, AdminDocsTestCase): + + def test_xview_func(self): + user = User.objects.get(username='super') + response = self.client.head('/xview/func/') + self.assertNotIn('X-View', response) + self.client.force_login(self.superuser) + response = self.client.head('/xview/func/') + self.assertIn('X-View', response) + self.assertEqual(response['X-View'], 'admin_docs.views.xview') + user.is_staff = False + user.save() + response = self.client.head('/xview/func/') + self.assertNotIn('X-View', response) + user.is_staff = True + user.is_active = False + user.save() + response = self.client.head('/xview/func/') + self.assertNotIn('X-View', response) + + def test_xview_class(self): + user = User.objects.get(username='super') + response = self.client.head('/xview/class/') + self.assertNotIn('X-View', response) + self.client.force_login(self.superuser) + response = self.client.head('/xview/class/') + self.assertIn('X-View', response) + self.assertEqual(response['X-View'], 'admin_docs.views.XViewClass') + user.is_staff = False + user.save() + response = self.client.head('/xview/class/') + self.assertNotIn('X-View', response) + user.is_staff = True + user.is_active = False + user.save() + response = self.client.head('/xview/class/') + self.assertNotIn('X-View', response) |
