From d50952a6e55a7b7dcb9d8457077727d2d45104e9 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 28 Nov 2016 18:20:40 +0000 Subject: [PATCH] Add test case for admin disabled --- project/common/tests.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/project/common/tests.py b/project/common/tests.py index 6a23357..66b6a65 100644 --- a/project/common/tests.py +++ b/project/common/tests.py @@ -13,3 +13,23 @@ class ContextInjectorTestCase(BaseTestCase): for key in SETTINGS_KEYS: self.assertIn(key, response.context['django_settings']) self.assertEqual(response.context['django_settings'][key], getattr(settings, key)) + + +class DjangoAdminDisabledTestCase(BaseTestCase): + def test_admin_enabled(self): + with self.settings(ENABLE_ADMIN=True): + response = self.client.get('/django-admin/login/', follow=True) + self.assertEqual(response.status_code, 200) + + with self.settings(DEBUG=True): + response = self.client.get('/django-admin/login/', follow=True) + self.assertEqual(response.status_code, 200) + + def test_admin_disabled(self): + with self.settings(ENABLE_ADMIN=False): + response = self.client.get('/django-admin/login/', follow=True) + self.assertEqual(response.status_code, 200) + + with self.settings(DEBUG=False): + response = self.client.get('/django-admin/login/', follow=True) + self.assertEqual(response.status_code, 200)