From 042e766be1824f46dbd2d3b8aac19383dff4f4c8 Mon Sep 17 00:00:00 2001 From: Janne Alatalo Date: Tue, 27 Aug 2019 12:33:03 +0300 Subject: [PATCH] Add a test that checks that LOGIN_URL can be a view name This test requires that the admin urls are added to the test configuration. --- helpdesk/tests/test_login.py | 8 ++++++++ helpdesk/tests/urls.py | 2 ++ 2 files changed, 10 insertions(+) diff --git a/helpdesk/tests/test_login.py b/helpdesk/tests/test_login.py index 8f28e962..800ae71d 100644 --- a/helpdesk/tests/test_login.py +++ b/helpdesk/tests/test_login.py @@ -35,3 +35,11 @@ class TestLoginRedirect(TestCase): """Test that default login is used when LOGIN_URL is None""" response = self.client.get(reverse('helpdesk:login')) self.assertTemplateUsed(response, 'helpdesk/registration/login.html') + + @override_settings(LOGIN_URL='admin:login', SITE_ID=1) + def test_custom_login_view_with_name(self): + """Test that LOGIN_URL can be a view name""" + response = self.client.get(reverse('helpdesk:login')) + home_url = reverse('helpdesk:home') + expected = reverse('admin:login') + "?next=" + home_url + self.assertRedirects(response, expected) diff --git a/helpdesk/tests/urls.py b/helpdesk/tests/urls.py index 12553ec3..640937c2 100644 --- a/helpdesk/tests/urls.py +++ b/helpdesk/tests/urls.py @@ -1,5 +1,7 @@ from django.conf.urls import include, url +from django.contrib import admin urlpatterns = [ url(r'^helpdesk/', include('helpdesk.urls', namespace='helpdesk')), + url(r'^admin/', admin.site.urls), ]