diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2020-05-14 10:27:35 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-05-14 11:00:51 +0200 |
| commit | d522b51c401429c169d88742178a9b3777903d9e (patch) | |
| tree | 3906605a21d2e83dbc44642bef2685432c4e141d /tests/admin_views | |
| parent | e341bed606d8ab2864838795276692cf86b08687 (diff) | |
Fixed #31575 -- Added system check for admin sidebar request context processor dependency.
Co-authored-by: Carlton Gibson <carlton.gibson@noumenal.es>
Diffstat (limited to 'tests/admin_views')
| -rw-r--r-- | tests/admin_views/test_nav_sidebar.py | 26 | ||||
| -rw-r--r-- | tests/admin_views/tests.py | 2 |
2 files changed, 26 insertions, 2 deletions
diff --git a/tests/admin_views/test_nav_sidebar.py b/tests/admin_views/test_nav_sidebar.py index 2225376cd5..9d52c541c0 100644 --- a/tests/admin_views/test_nav_sidebar.py +++ b/tests/admin_views/test_nav_sidebar.py @@ -51,9 +51,31 @@ class AdminSidebarTests(TestCase): self.assertNotContains(response, '<nav class="sticky" id="nav-sidebar">') def test_sidebar_aria_current_page(self): - response = self.client.get(reverse('test_with_sidebar:auth_user_changelist')) + url = reverse('test_with_sidebar:auth_user_changelist') + response = self.client.get(url) self.assertContains(response, '<nav class="sticky" id="nav-sidebar">') - self.assertContains(response, 'aria-current="page">Users</a>') + self.assertContains(response, '<a href="%s" aria-current="page">Users</a>' % url) + + @override_settings( + TEMPLATES=[{ + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }] + ) + def test_sidebar_aria_current_page_missing_without_request_context_processor(self): + url = reverse('test_with_sidebar:auth_user_changelist') + response = self.client.get(url) + self.assertContains(response, '<nav class="sticky" id="nav-sidebar">') + # Does not include aria-current attribute. + self.assertContains(response, '<a href="%s">Users</a>' % url) + self.assertNotContains(response, 'aria-current') @override_settings(ROOT_URLCONF='admin_views.test_nav_sidebar') diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 03ec445eeb..eb6f009f03 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -1425,6 +1425,7 @@ def get_perm(Model, codename): 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ + 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], @@ -2424,6 +2425,7 @@ class AdminViewPermissionsTest(TestCase): 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ + 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], |
