Django

Code

Show
Ignore:
Timestamp:
06/30/08 10:38:16 (6 months ago)
Author:
brosner
Message:

newforms-admin: Merged from trunk up to [7808]. Fixed #7519, #7573

Files:

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  
    5555u'!' 
    5656""" 
     57 
     58from django.test import TestCase 
     59from django.core import mail 
     60 
     61class 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 mail 
    3 from django.test import TestCase 
    4 from django.contrib.auth.models import User 
    5 from django.contrib.auth.forms import PasswordResetForm 
    6  
    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 tests 
    25         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 text 
    29         # self.assertEqual(mail.outbox[0].body, '') 
    301 
    312FORM_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, PasswordResetFormTestCase 
     1from django.contrib.auth.tests.basic import BASIC_TESTS, PasswordResetTest 
     2from django.contrib.auth.tests.forms import FORM_TESTS 
    33 
    44__test__ = { 
    55    'BASIC_TESTS': BASIC_TESTS, 
    6     'PASSWORDRESET_TESTS': PasswordResetFormTestCase
     6    'PASSWORDRESET_TESTS': PasswordResetTest
    77    'FORM_TESTS': FORM_TESTS, 
    88}