Ticket #16789: t16789-with-docs-and-tests.diff

File t16789-with-docs-and-tests.diff, 7.3 KB (added by Chris Heisel, 13 years ago)

Docs and tests

  • django/contrib/auth/tests/__init__.py

    diff --git a/django/contrib/auth/tests/__init__.py b/django/contrib/auth/tests/__init__.py
    index 143b19c..d4e30cc 100644
    a b from django.contrib.auth.tests.management import GetDefaultUsernameTestCase  
    1313from django.contrib.auth.tests.models import ProfileTestCase
    1414from django.contrib.auth.tests.signals import SignalTestCase
    1515from django.contrib.auth.tests.tokens import TokenGeneratorTest
    16 from django.contrib.auth.tests.views import (PasswordResetTest,
     16from django.contrib.auth.tests.views import (AuthViewNamedURLTests, PasswordResetTest,
    1717    ChangePasswordTest, LoginTest, LogoutTest, LoginURLSettings)
    1818
    1919# The password for the fixture data users is 'password'
  • django/contrib/auth/tests/views.py

    diff --git a/django/contrib/auth/tests/views.py b/django/contrib/auth/tests/views.py
    index feca899..6e208f5 100644
    a b from django.core import mail  
    1313from django.core.urlresolvers import reverse
    1414from django.http import QueryDict
    1515
     16
    1617class AuthViewsTestCase(TestCase):
    1718    """
    1819    Helper base class for all the follow test cases.
    class AuthViewsTestCase(TestCase):  
    4546        self.assertTrue(response['Location'].endswith(settings.LOGIN_REDIRECT_URL))
    4647        self.assertTrue(SESSION_KEY in self.client.session)
    4748
     49
     50class AuthViewNamedURLTests(AuthViewsTestCase):
     51    urls = 'django.contrib.auth.urls'
     52
     53    def test_named_urls(self):
     54        "Named URLs should be reversible"
     55        expected_named_urls = [
     56            ('login', [], {}),
     57            ('logout', [], {}),
     58            ('password_change', [], {}),
     59            ('password_change_done', [], {}),
     60            ('password_reset', [], {}),
     61            ('password_reset_done', [], {}),
     62            ('password_reset_confirm', [], {
     63                'uidb36': 'aaaaaaa',
     64                'token': '1111-aaaaa',
     65            }),
     66            ('password_reset_complete', [], {}),
     67        ]
     68        for name, args, kwargs in expected_named_urls:
     69            self.assert_(reverse(name, args=args, kwargs=kwargs))
     70
     71
    4872class PasswordResetTest(AuthViewsTestCase):
    4973
    5074    def test_email_not_found(self):
  • django/contrib/auth/urls.py

    diff --git a/django/contrib/auth/urls.py b/django/contrib/auth/urls.py
    index 42b4e8f..b32b796 100644
    a b  
    1 # These URLs are normally mapped to /admin/urls.py. This URLs file is
    2 # provided as a convenience to those who want to deploy these URLs elsewhere.
     1# This URLs file is provided as a convenience to those who want to deploy these URLs elsewhere.
    32# This file is also used to provide a reliable view deployment for test purposes.
    43
    5 from django.conf.urls.defaults import *
     4from django.conf.urls.defaults import patterns, url
    65
    76urlpatterns = patterns('',
    8     (r'^login/$', 'django.contrib.auth.views.login'),
    9     (r'^logout/$', 'django.contrib.auth.views.logout'),
    10     (r'^password_change/$', 'django.contrib.auth.views.password_change'),
    11     (r'^password_change/done/$', 'django.contrib.auth.views.password_change_done'),
    12     (r'^password_reset/$', 'django.contrib.auth.views.password_reset'),
    13     (r'^password_reset/done/$', 'django.contrib.auth.views.password_reset_done'),
    14     (r'^reset/(?P<uidb36>[0-9A-Za-z]{1,13})-(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', 'django.contrib.auth.views.password_reset_confirm'),
    15     (r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete'),
     7    url(r'^login/$', 'django.contrib.auth.views.login', name='login'),
     8    url(r'^logout/$', 'django.contrib.auth.views.logout', name='logout'),
     9    url(r'^password_change/$', 'django.contrib.auth.views.password_change', name='password_change'),
     10    url(r'^password_change/done/$', 'django.contrib.auth.views.password_change_done', name='password_change_done'),
     11    url(r'^password_reset/$', 'django.contrib.auth.views.password_reset', name='password_reset'),
     12    url(r'^password_reset/done/$', 'django.contrib.auth.views.password_reset_done', name='password_reset_done'),
     13    url(r'^reset/(?P<uidb36>[0-9A-Za-z]{1,13})-(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', 'django.contrib.auth.views.password_reset_confirm', name='password_reset_confirm'),
     14    url(r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete', name='password_reset_complete'),
    1615)
    17 
  • docs/topics/auth.txt

    diff --git a/docs/topics/auth.txt b/docs/topics/auth.txt
    index 69f6fd7..08673fa 100644
    a b The login_required decorator  
    823823
    824824.. function:: views.login(request, [template_name, redirect_field_name, authentication_form])
    825825
     826    **URL name:** ``login``
     827
     828    See :doc:`the URL documentation </topics/http/urls>` for details on using named URL patterns
     829
    826830    Here's what ``django.contrib.auth.views.login`` does:
    827831
    828832        * If called via ``GET``, it displays a login form that POSTs to the
    includes a few other useful built-in views located in  
    938942
    939943    Logs a user out.
    940944
     945    **URL name:** ``logout``
     946
     947    See :doc:`the URL documentation </topics/http/urls>` for details on using named URL patterns
     948
     949
    941950    **Optional arguments:**
    942951
    943952        * ``next_page``: The URL to redirect to after logout.
    includes a few other useful built-in views located in  
    970979
    971980    Logs a user out, then redirects to the login page.
    972981
     982    **URL name:** No default URL provided
     983
    973984    **Optional arguments:**
    974985
    975986        * ``login_url``: The URL of the login page to redirect to.
    includes a few other useful built-in views located in  
    979990
    980991    Allows a user to change their password.
    981992
     993    **URL name:** ``password_change``
     994
    982995    **Optional arguments:**
    983996
    984997        * ``template_name``: The full name of a template to use for
    includes a few other useful built-in views located in  
    10031016
    10041017    The page shown after a user has changed their password.
    10051018
     1019    **URL name:** ``password_change_done``
     1020
    10061021    **Optional arguments:**
    10071022
    10081023        * ``template_name``: The full name of a template to use.
    includes a few other useful built-in views located in  
    10241039        will not be able to request a password reset to prevent misuse
    10251040        when using an external authentication source like LDAP.
    10261041
     1042    **URL name:** ``password_reset``
     1043
    10271044    **Optional arguments:**
    10281045
    10291046        * ``template_name``: The full name of a template to use for
    includes a few other useful built-in views located in  
    10991116    password. This view is called by default if the :func:`password_reset` view
    11001117    doesn't have an explicit ``post_reset_redirect`` URL set.
    11011118
     1119    **URL name:** ``password_reset_done``
     1120
    11021121    **Optional arguments:**
    11031122
    11041123        * ``template_name``: The full name of a template to use.
    includes a few other useful built-in views located in  
    11091128
    11101129    Presents a form for entering a new password.
    11111130
     1131    **URL name:** ``password_reset_confirm``
     1132
    11121133    **Optional arguments:**
    11131134
    11141135        * ``uidb36``: The user's id encoded in base 36. Defaults to ``None``.
    includes a few other useful built-in views located in  
    11421163   Presents a view which informs the user that the password has been
    11431164   successfully changed.
    11441165
     1166   **URL name:** ``password_reset_complete``
     1167
    11451168   **Optional arguments:**
    11461169
    11471170       * ``template_name``: The full name of a template to display the view.
Back to Top