diff options
| author | Florian Apolloner <florian@apolloner.eu> | 2015-11-07 16:12:37 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-05-17 07:22:22 -0400 |
| commit | 9baf692a58de78dba13aa582098781675367c329 (patch) | |
| tree | 1926555441d0c3b13185782dce193b839d616a4a /tests/auth_tests/test_context_processors.py | |
| parent | 05c888ffb843ba3eff06cd07b3cef5bbb513a54f (diff) | |
Fixed #26601 -- Improved middleware per DEP 0005.
Thanks Tim Graham for polishing the patch, updating the tests, and
writing documentation. Thanks Carl Meyer for shepherding the DEP.
Diffstat (limited to 'tests/auth_tests/test_context_processors.py')
| -rw-r--r-- | tests/auth_tests/test_context_processors.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/auth_tests/test_context_processors.py b/tests/auth_tests/test_context_processors.py index 3a8d800c74..d1db63c7b2 100644 --- a/tests/auth_tests/test_context_processors.py +++ b/tests/auth_tests/test_context_processors.py @@ -5,7 +5,7 @@ from django.contrib.contenttypes.models import ContentType from django.db.models import Q from django.test import SimpleTestCase, TestCase, override_settings -from .settings import AUTH_MIDDLEWARE_CLASSES, AUTH_TEMPLATES +from .settings import AUTH_MIDDLEWARE, AUTH_TEMPLATES class MockUser(object): @@ -67,7 +67,7 @@ class AuthContextProcessorTests(TestCase): def setUpTestData(cls): cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.com') - @override_settings(MIDDLEWARE_CLASSES=AUTH_MIDDLEWARE_CLASSES) + @override_settings(MIDDLEWARE=AUTH_MIDDLEWARE) def test_session_not_accessed(self): """ Tests that the session is not accessed simply by including @@ -76,7 +76,12 @@ class AuthContextProcessorTests(TestCase): response = self.client.get('/auth_processor_no_attr_access/') self.assertContains(response, "Session not accessed") - @override_settings(MIDDLEWARE_CLASSES=AUTH_MIDDLEWARE_CLASSES) + @override_settings(MIDDLEWARE_CLASSES=AUTH_MIDDLEWARE, MIDDLEWARE=None) + def test_session_not_accessed_middleware_classes(self): + response = self.client.get('/auth_processor_no_attr_access/') + self.assertContains(response, "Session not accessed") + + @override_settings(MIDDLEWARE=AUTH_MIDDLEWARE) def test_session_is_accessed(self): """ Tests that the session is accessed if the auth context processor @@ -85,6 +90,11 @@ class AuthContextProcessorTests(TestCase): response = self.client.get('/auth_processor_attr_access/') self.assertContains(response, "Session accessed") + @override_settings(MIDDLEWARE_CLASSES=AUTH_MIDDLEWARE, MIDDLEWARE=None) + def test_session_is_accessed_middleware_classes(self): + response = self.client.get('/auth_processor_attr_access/') + self.assertContains(response, "Session accessed") + def test_perms_attrs(self): u = User.objects.create_user(username='normal', password='secret') u.user_permissions.add( |
