Changeset 7809 for django/branches/newforms-admin/django/contrib/auth/tests
- Timestamp:
- 06/30/08 10:38:16 (6 months ago)
- Files:
-
- django/branches/newforms-admin (modified) (1 prop)
- django/branches/newforms-admin/django/contrib/auth/tests/basic.py (modified) (1 diff)
- django/branches/newforms-admin/django/contrib/auth/tests/forms.py (modified) (1 diff)
- django/branches/newforms-admin/django/contrib/auth/tests/__init__.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/newforms-admin
- Property svnmerge-integrated changed from /django/trunk:1-4345,4350-4357,4359-4365,4371-4372,4374-4377,4380-4386,4388,4390-4391,4400-4402,4404-4408,4410,4412-4419,4426-4427,4430-4432,4434,4441,4443-4444,4446-4447,4450,4452-4453,4455-4458,4476,4503,4546,4564-4569,4580-4586,4617,4630,4641-6390,6392-7768 to /django/trunk:1-4345,4350-4357,4359-4365,4371-4372,4374-4377,4380-4386,4388,4390-4391,4400-4402,4404-4408,4410,4412-4419,4426-4427,4430-4432,4434,4441,4443-4444,4446-4447,4450,4452-4453,4455-4458,4476,4503,4546,4564-4569,4580-4586,4617,4630,4641-6390,6392-7808
django/branches/newforms-admin/django/contrib/auth/tests/basic.py
r7604 r7809 55 55 u'!' 56 56 """ 57 58 from django.test import TestCase 59 from django.core import mail 60 61 class PasswordResetTest(TestCase): 62 fixtures = ['authtestdata.json'] 63 urls = 'django.contrib.auth.urls' 64 65 def test_email_not_found(self): 66 "Error is raised if the provided email address isn't currently registered" 67 response = self.client.get('/password_reset/') 68 self.assertEquals(response.status_code, 200) 69 response = self.client.post('/password_reset/', {'email': 'not_a_real_email@email.com'}) 70 self.assertContains(response, "That e-mail address doesn't have an associated user account") 71 self.assertEquals(len(mail.outbox), 0) 72 73 def test_email_found(self): 74 "Email is sent if a valid email address is provided for password reset" 75 response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'}) 76 self.assertEquals(response.status_code, 302) 77 self.assertEquals(len(mail.outbox), 1) django/branches/newforms-admin/django/contrib/auth/tests/forms.py
r7191 r7809 1 2 from django.core import mail3 from django.test import TestCase4 from django.contrib.auth.models import User5 from django.contrib.auth.forms import PasswordResetForm6 7 class PasswordResetFormTestCase(TestCase):8 def testValidUser(self):9 data = {10 'email': 'nonexistent@example.com',11 }12 form = PasswordResetForm(data)13 self.assertEqual(form.is_valid(), False)14 self.assertEqual(form["email"].errors, [u"That e-mail address doesn't have an associated user account. Are you sure you've registered?"])15 16 def testEmail(self):17 # TODO: remove my email address from the test ;)18 User.objects.create_user('atestuser', 'atestuser@example.com', 'test789')19 data = {20 'email': 'atestuser@example.com',21 }22 form = PasswordResetForm(data)23 self.assertEqual(form.is_valid(), True)24 # TODO: look at why using contrib.sites breaks other tests25 form.save(domain_override="example.com")26 self.assertEqual(len(mail.outbox), 1)27 self.assertEqual(mail.outbox[0].subject, u'Password reset on example.com')28 # TODO: test mail body. need to figure out a way to get the password in plain text29 # self.assertEqual(mail.outbox[0].body, '')30 1 31 2 FORM_TESTS = """ django/branches/newforms-admin/django/contrib/auth/tests/__init__.py
r7191 r7809 1 from django.contrib.auth.tests.basic import BASIC_TESTS 2 from django.contrib.auth.tests.forms import FORM_TESTS , PasswordResetFormTestCase1 from django.contrib.auth.tests.basic import BASIC_TESTS, PasswordResetTest 2 from django.contrib.auth.tests.forms import FORM_TESTS 3 3 4 4 __test__ = { 5 5 'BASIC_TESTS': BASIC_TESTS, 6 'PASSWORDRESET_TESTS': PasswordReset FormTestCase,6 'PASSWORDRESET_TESTS': PasswordResetTest, 7 7 'FORM_TESTS': FORM_TESTS, 8 8 }
