Ticket #15266: views_and_tests.diff

File views_and_tests.diff, 1.6 KB (added by lasko, 4 years ago)

patch for views.py and also added tests.

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

    diff --git a/django/contrib/auth/tests/views.py b/django/contrib/auth/tests/views.py
    index b03489c..be1d89c 100644
    a b class ChangePasswordTest(AuthViewsTestCase): 
    193193        self.fail_login()
    194194        self.login(password='password1')
    195195
     196    def test_password_change_done_succeeds(self):
     197        self.login()
     198        response = self.client.post('/password_change/', {
     199            'old_password': 'password',
     200            'new_password1': 'password1',
     201            'new_password2': 'password1',
     202            }
     203        )
     204        self.assertEqual(response.status_code, 302)
     205        self.assertTrue(response['Location'].endswith('/password_change/done/'))
     206
     207    def test_password_change_done_fails(self):
     208        response = self.client.get('/password_change/done/')
     209        self.assertEquL(response.status_code, 302)
     210        self.assertTrue(response['Location'].endswith('/login/'))
     211       
     212       
    196213class LoginTest(AuthViewsTestCase):
    197214
    198215    def test_current_site_in_context_after_login(self):
  • django/contrib/auth/views.py

    diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py
    index eba83a2..53fa60b 100644
    a b def password_change(request, 
    245245    return render_to_response(template_name, context,
    246246                              context_instance=RequestContext(request, current_app=current_app))
    247247
     248@login_required
    248249def password_change_done(request,
    249250                         template_name='registration/password_change_done.html',
    250251                         current_app=None, extra_context=None):
Back to Top