diff options
| author | Claude Paroz <claude@2xlibre.net> | 2016-08-14 22:42:49 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2019-02-14 10:23:02 -0500 |
| commit | a8e2a9bac6e548d6ab2e13af6171d2fdd3b8055b (patch) | |
| tree | f49b5f5f14b5a8d8f907efee6079a4e3b51ce72c /tests/auth_tests | |
| parent | 76990cbbda5d93fda560c8a5ab019860f7efaab7 (diff) | |
Refs #15902 -- Deprecated storing user's language in the session.
Diffstat (limited to 'tests/auth_tests')
| -rw-r--r-- | tests/auth_tests/test_views.py | 15 | ||||
| -rw-r--r-- | tests/auth_tests/urls.py | 2 |
2 files changed, 7 insertions, 10 deletions
diff --git a/tests/auth_tests/test_views.py b/tests/auth_tests/test_views.py index 4949ce1bf4..f738a73e64 100644 --- a/tests/auth_tests/test_views.py +++ b/tests/auth_tests/test_views.py @@ -31,7 +31,6 @@ from django.test import Client, TestCase, override_settings from django.test.client import RedirectCycleError from django.urls import NoReverseMatch, reverse, reverse_lazy from django.utils.http import urlsafe_base64_encode -from django.utils.translation import LANGUAGE_SESSION_KEY from .client import PasswordResetConfirmClient from .models import CustomUser, UUIDUser @@ -1075,16 +1074,12 @@ class LogoutTest(AuthViewsTestCase): self.confirm_logged_out() def test_logout_preserve_language(self): - """Language stored in session is preserved after logout""" - # Create a new session with language - engine = import_module(settings.SESSION_ENGINE) - session = engine.SessionStore() - session[LANGUAGE_SESSION_KEY] = 'pl' - session.save() - self.client.cookies[settings.SESSION_COOKIE_NAME] = session.session_key - + """Language is preserved after logout.""" + self.login() + self.client.post('/setlang/', {'language': 'pl'}) + self.assertEqual(self.client.cookies[settings.LANGUAGE_COOKIE_NAME].value, 'pl') self.client.get('/logout/') - self.assertEqual(self.client.session[LANGUAGE_SESSION_KEY], 'pl') + self.assertEqual(self.client.cookies[settings.LANGUAGE_COOKIE_NAME].value, 'pl') @override_settings(LOGOUT_REDIRECT_URL='/custom/') def test_logout_redirect_url_setting(self): diff --git a/tests/auth_tests/urls.py b/tests/auth_tests/urls.py index d0b259935b..142a2b49c2 100644 --- a/tests/auth_tests/urls.py +++ b/tests/auth_tests/urls.py @@ -9,6 +9,7 @@ from django.shortcuts import render from django.template import RequestContext, Template from django.urls import path, re_path, reverse_lazy from django.views.decorators.cache import never_cache +from django.views.i18n import set_language class CustomRequestAuthenticationForm(AuthenticationForm): @@ -148,6 +149,7 @@ urlpatterns = auth_urlpatterns + [ path('permission_required_exception/', permission_required_exception), path('login_and_permission_required_exception/', login_and_permission_required_exception), + path('setlang/', set_language, name='set_language'), # This line is only required to render the password reset with is_admin=True path('admin/', admin.site.urls), ] |
