Django

Code

Changeset 7716

Show
Ignore:
Timestamp:
06/20/08 12:43:12 (3 months ago)
Author:
lukeplant
Message:

Added basic tests for auth.views.password_reset

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/auth/tests.py

    r7590 r7716  
    11""" 
    2 >>> from models import User, AnonymousUser 
     2>>> from django.contrib.auth.models import User, AnonymousUser 
    33>>> u = User.objects.create_user('testuser', 'test@example.com', 'testpw') 
    44>>> u.has_usable_password() 
     
    5454u'!' 
    5555""" 
     56 
     57from django.test import TestCase 
     58from django.core import mail 
     59 
     60class PasswordResetTest(TestCase): 
     61    fixtures = ['authtestdata.json'] 
     62    def test_email_not_found(self): 
     63        response = self.client.get('/auth/password_reset/') 
     64        self.assertEquals(response.status_code, 200) 
     65        response = self.client.post('/auth/password_reset/', {'email': 'not_a_real_email@email.com'} ) 
     66        self.assertContains(response, "That e-mail address doesn't have an associated user account") 
     67        self.assertEquals(len(mail.outbox), 0) 
     68 
     69    def test_email_found(self): 
     70        response = self.client.post('/auth/password_reset/', {'email': 'staffmember@example.com'} ) 
     71        self.assertEquals(response.status_code, 302) 
     72        self.assertEquals(len(mail.outbox), 1) 
  • django/trunk/tests/urls.py

    r7328 r7716  
    2323    # test urlconf for syndication tests 
    2424    (r'^syndication/', include('regressiontests.syndication.urls')), 
     25 
     26    # Other contrib apps 
     27    (r'^auth/', include('django.contrib.auth.urls')), 
    2528)