diff options
author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2022-04-16 20:27:49 +0200 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-04-20 10:04:29 +0200 |
commit | 5dfa6fca967cd1ba5a0d40013a298b7e52b0822b (patch) | |
tree | c99faecbd58a445c6b2bc9a3ebb0f97bc90dfd43 /tests/auth_tests | |
parent | 04bc2564b6e0a1a0f75bb5f015e47c96c86fa0be (diff) | |
download | django-5dfa6fca967cd1ba5a0d40013a298b7e52b0822b.tar.gz |
Refactored out RedirectURLMixin.get_success_url().
This also adds a default implementation of get_default_redirect_url().
Diffstat (limited to 'tests/auth_tests')
-rw-r--r-- | tests/auth_tests/test_views.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auth_tests/test_views.py b/tests/auth_tests/test_views.py index 86424636b7..2941716422 100644 --- a/tests/auth_tests/test_views.py +++ b/tests/auth_tests/test_views.py @@ -18,6 +18,7 @@ from django.contrib.auth.models import Permission, User from django.contrib.auth.views import ( INTERNAL_RESET_SESSION_TOKEN, LoginView, + RedirectURLMixin, logout_then_login, redirect_to_login, ) @@ -40,6 +41,20 @@ from .models import CustomUser, UUIDUser from .settings import AUTH_TEMPLATES +class RedirectURLMixinTests(TestCase): + @override_settings(ROOT_URLCONF="auth_tests.urls") + def test_get_default_redirect_url_next_page(self): + class RedirectURLView(RedirectURLMixin): + next_page = "/custom/" + + self.assertEqual(RedirectURLView().get_default_redirect_url(), "/custom/") + + def test_get_default_redirect_url_no_next_page(self): + msg = "No URL to redirect to. Provide a next_page." + with self.assertRaisesMessage(ImproperlyConfigured, msg): + RedirectURLMixin().get_default_redirect_url() + + @override_settings( LANGUAGES=[("en", "English")], LANGUAGE_CODE="en", |