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.
This commit is contained in:
Janne Alatalo 2019-08-27 12:33:03 +03:00
parent 0a43b9a160
commit 042e766be1
2 changed files with 10 additions and 0 deletions

View File

@ -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)

View File

@ -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),
]