Django

Code

Changeset 7808

Show
Ignore:
Timestamp:
06/30/08 08:11:12 (1 year ago)
Author:
russellm
Message:

Refs #7521 -- Re-reverted [7716] (originally reverted in [7726]), now modified to use the new TestCase? urlpattern framework.

Files:

Legend:

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

    r7726 r7808  
    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    urls = 'django.contrib.auth.urls' 
     63    def test_email_not_found(self): 
     64        "Error is raised if the provided email address isn't currently registered" 
     65        response = self.client.get('/password_reset/') 
     66        self.assertEquals(response.status_code, 200) 
     67        response = self.client.post('/password_reset/', {'email': 'not_a_real_email@email.com'}) 
     68        self.assertContains(response, "That e-mail address doesn't have an associated user account") 
     69        self.assertEquals(len(mail.outbox), 0) 
     70 
     71    def test_email_found(self): 
     72        "Email is sent if a valid email address is provided for password reset" 
     73        response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'}) 
     74        self.assertEquals(response.status_code, 302) 
     75        self.assertEquals(len(mail.outbox), 1) 
  • django/trunk/django/contrib/auth/urls.py

    r7716 r7808  
    1 # This exists for the sake of testing only.  Normally URLs are mapped in 
    2 # ../admin/urls.py 
     1# These URLs are normally mapped to /admin/urls.py. This URLs file is  
     2# provided as a convenience to those who want to deploy these URLs elsewhere. 
     3# This file is also used to provide a reliable view deployment for test purposes. 
    34 
    45from django.conf.urls.defaults import *