Ticket #24097: test_redirect_to_login.diff

File test_redirect_to_login.diff, 1.4 KB (added by Peter Schmidt, 10 years ago)
  • django/contrib/auth/tests/test_views.py

    diff --git a/django/contrib/auth/tests/test_views.py b/django/contrib/auth/tests/test_views.py
    index d406b43..85fe458 100644
    a b from django.contrib.auth import SESSION_KEY, REDIRECT_FIELD_NAME  
    1010from django.contrib.auth.forms import (AuthenticationForm, PasswordChangeForm,
    1111    SetPasswordForm)
    1212from django.contrib.auth.models import User
    13 from django.contrib.auth.views import login as login_view
     13from django.contrib.auth.views import login as login_view, redirect_to_login
    1414from django.core import mail
    15 from django.core.urlresolvers import reverse, NoReverseMatch
     15from django.core.urlresolvers import NoReverseMatch, reverse, reverse_lazy
    1616from django.http import QueryDict, HttpRequest
    1717from django.utils.deprecation import RemovedInDjango20Warning
    1818from django.utils.encoding import force_text
    class LoginRedirectUrlTest(AuthViewsTestCase):  
    673673        self.assertLoginRedirectURLEqual('http://remote.example.com/welcome/')
    674674
    675675
     676class LazyLoginURLTest(AuthViewsTestCase):
     677    def test_redirect_to_login(self):
     678        with self.settings(LOGIN_URL=reverse_lazy('login')):
     679            login_redirect_response = redirect_to_login(next='/else/where/')
     680            expected = '/login/?next=/else/where/'
     681            self.assertEquals(expected, login_redirect_response.url)
     682
     683
    676684@skipIfCustomUser
    677685class LogoutTest(AuthViewsTestCase):
    678686
Back to Top