1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Refs #17209 -- Added LoginView and LogoutView class-based views

Thanks Tim Graham for the review.
This commit is contained in:
Claude Paroz
2016-05-15 17:28:00 +02:00
parent 742ea51413
commit 78963495d0
16 changed files with 226 additions and 157 deletions

View File

@@ -1,12 +1,12 @@
from __future__ import unicode_literals
from django.contrib.auth.views import logout
from django.shortcuts import resolve_url
from django.test import SimpleTestCase, override_settings
from django.urls import NoReverseMatch, reverse_lazy
from django.utils import six
from .models import UnimportantThing
from .urls import some_view
@override_settings(ROOT_URLCONF='resolve_url.urls')
@@ -53,25 +53,25 @@ class ResolveUrlTests(SimpleTestCase):
Tests that passing a view function to ``resolve_url`` will result in
the URL path mapping to that view name.
"""
resolved_url = resolve_url(logout)
self.assertEqual('/accounts/logout/', resolved_url)
resolved_url = resolve_url(some_view)
self.assertEqual('/some-url/', resolved_url)
def test_lazy_reverse(self):
"""
Tests that passing the result of reverse_lazy is resolved to a real URL
string.
"""
resolved_url = resolve_url(reverse_lazy('logout'))
resolved_url = resolve_url(reverse_lazy('some-view'))
self.assertIsInstance(resolved_url, six.text_type)
self.assertEqual('/accounts/logout/', resolved_url)
self.assertEqual('/some-url/', resolved_url)
def test_valid_view_name(self):
"""
Tests that passing a view name to ``resolve_url`` will result in the
URL path mapping to that view.
"""
resolved_url = resolve_url('logout')
self.assertEqual('/accounts/logout/', resolved_url)
resolved_url = resolve_url('some-view')
self.assertEqual('/some-url/', resolved_url)
def test_domain(self):
"""