diff options
Diffstat (limited to 'django/contrib/auth/tests.py')
-rw-r--r-- | django/contrib/auth/tests.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/django/contrib/auth/tests.py b/django/contrib/auth/tests.py index 81094ca85f..e09f379456 100644 --- a/django/contrib/auth/tests.py +++ b/django/contrib/auth/tests.py @@ -1,5 +1,5 @@ """ ->>> from models import User, AnonymousUser +>>> from django.contrib.auth.models import User, AnonymousUser >>> u = User.objects.create_user('testuser', 'test@example.com', 'testpw') >>> u.has_usable_password() True @@ -52,4 +52,21 @@ Superuser created successfully. u'joe@somewhere.org' >>> u.password u'!' -"""
\ No newline at end of file +""" + +from django.test import TestCase +from django.core import mail + +class PasswordResetTest(TestCase): + fixtures = ['authtestdata.json'] + def test_email_not_found(self): + response = self.client.get('/auth/password_reset/') + self.assertEquals(response.status_code, 200) + response = self.client.post('/auth/password_reset/', {'email': 'not_a_real_email@email.com'} ) + self.assertContains(response, "That e-mail address doesn't have an associated user account") + self.assertEquals(len(mail.outbox), 0) + + def test_email_found(self): + response = self.client.post('/auth/password_reset/', {'email': 'staffmember@example.com'} ) + self.assertEquals(response.status_code, 302) + self.assertEquals(len(mail.outbox), 1) |