mirror of https://github.com/django/django.git
Cleaned formatting/comments in PasswordResetFormTest
This commit is contained in:
parent
f8632572ad
commit
59a8808632
|
@ -360,14 +360,21 @@ class UserChangeFormTest(TestCase):
|
||||||
|
|
||||||
|
|
||||||
@skipIfCustomUser
|
@skipIfCustomUser
|
||||||
@override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
@override_settings(
|
||||||
|
PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
|
||||||
|
TEMPLATE_LOADERS=('django.template.loaders.filesystem.Loader',),
|
||||||
|
TEMPLATE_DIRS=(
|
||||||
|
os.path.join(os.path.dirname(upath(__file__)), 'templates'),
|
||||||
|
),
|
||||||
|
USE_TZ=False,
|
||||||
|
)
|
||||||
class PasswordResetFormTest(TestCase):
|
class PasswordResetFormTest(TestCase):
|
||||||
|
|
||||||
fixtures = ['authtestdata.json']
|
fixtures = ['authtestdata.json']
|
||||||
|
|
||||||
def create_dummy_user(self):
|
def create_dummy_user(self):
|
||||||
"""creates a user and returns a tuple
|
"""
|
||||||
(user_object, username, email)
|
Create a user and return a tuple (user_object, username, email).
|
||||||
"""
|
"""
|
||||||
username = 'jsmith'
|
username = 'jsmith'
|
||||||
email = 'jsmith@example.com'
|
email = 'jsmith@example.com'
|
||||||
|
@ -381,21 +388,16 @@ class PasswordResetFormTest(TestCase):
|
||||||
self.assertEqual(form['email'].errors, [_('Enter a valid email address.')])
|
self.assertEqual(form['email'].errors, [_('Enter a valid email address.')])
|
||||||
|
|
||||||
def test_nonexistant_email(self):
|
def test_nonexistant_email(self):
|
||||||
# Test nonexistant email address. This should not fail because it would
|
"""
|
||||||
# expose information about registered users.
|
Test nonexistant email address. This should not fail because it would
|
||||||
|
expose information about registered users.
|
||||||
|
"""
|
||||||
data = {'email': 'foo@bar.com'}
|
data = {'email': 'foo@bar.com'}
|
||||||
form = PasswordResetForm(data)
|
form = PasswordResetForm(data)
|
||||||
self.assertTrue(form.is_valid())
|
self.assertTrue(form.is_valid())
|
||||||
self.assertEqual(len(mail.outbox), 0)
|
self.assertEqual(len(mail.outbox), 0)
|
||||||
|
|
||||||
@override_settings(
|
|
||||||
TEMPLATE_LOADERS=('django.template.loaders.filesystem.Loader',),
|
|
||||||
TEMPLATE_DIRS=(
|
|
||||||
os.path.join(os.path.dirname(upath(__file__)), 'templates'),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
def test_cleaned_data(self):
|
def test_cleaned_data(self):
|
||||||
# Regression test
|
|
||||||
(user, username, email) = self.create_dummy_user()
|
(user, username, email) = self.create_dummy_user()
|
||||||
data = {'email': email}
|
data = {'email': email}
|
||||||
form = PasswordResetForm(data)
|
form = PasswordResetForm(data)
|
||||||
|
@ -404,12 +406,6 @@ class PasswordResetFormTest(TestCase):
|
||||||
self.assertEqual(form.cleaned_data['email'], email)
|
self.assertEqual(form.cleaned_data['email'], email)
|
||||||
self.assertEqual(len(mail.outbox), 1)
|
self.assertEqual(len(mail.outbox), 1)
|
||||||
|
|
||||||
@override_settings(
|
|
||||||
TEMPLATE_LOADERS=('django.template.loaders.filesystem.Loader',),
|
|
||||||
TEMPLATE_DIRS=(
|
|
||||||
os.path.join(os.path.dirname(upath(__file__)), 'templates'),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
def test_custom_email_subject(self):
|
def test_custom_email_subject(self):
|
||||||
data = {'email': 'testclient@example.com'}
|
data = {'email': 'testclient@example.com'}
|
||||||
form = PasswordResetForm(data)
|
form = PasswordResetForm(data)
|
||||||
|
@ -421,17 +417,20 @@ class PasswordResetFormTest(TestCase):
|
||||||
self.assertEqual(len(mail.outbox), 1)
|
self.assertEqual(len(mail.outbox), 1)
|
||||||
self.assertEqual(mail.outbox[0].subject, 'Custom password reset on example.com')
|
self.assertEqual(mail.outbox[0].subject, 'Custom password reset on example.com')
|
||||||
|
|
||||||
def test_bug_5605(self):
|
def test_preserve_username_case(self):
|
||||||
# bug #5605, preserve the case of the user name (before the @ in the
|
"""
|
||||||
# email address) when creating a user.
|
Preserve the case of the user name (before the @ in the email address)
|
||||||
|
when creating a user (#5605).
|
||||||
|
"""
|
||||||
user = User.objects.create_user('forms_test2', 'tesT@EXAMple.com', 'test')
|
user = User.objects.create_user('forms_test2', 'tesT@EXAMple.com', 'test')
|
||||||
self.assertEqual(user.email, 'tesT@example.com')
|
self.assertEqual(user.email, 'tesT@example.com')
|
||||||
user = User.objects.create_user('forms_test3', 'tesT', 'test')
|
user = User.objects.create_user('forms_test3', 'tesT', 'test')
|
||||||
self.assertEqual(user.email, 'tesT')
|
self.assertEqual(user.email, 'tesT')
|
||||||
|
|
||||||
def test_inactive_user(self):
|
def test_inactive_user(self):
|
||||||
#tests that inactive user cannot
|
"""
|
||||||
#receive password reset email
|
Test that inactive user cannot receive password reset email.
|
||||||
|
"""
|
||||||
(user, username, email) = self.create_dummy_user()
|
(user, username, email) = self.create_dummy_user()
|
||||||
user.is_active = False
|
user.is_active = False
|
||||||
user.save()
|
user.save()
|
||||||
|
@ -452,12 +451,6 @@ class PasswordResetFormTest(TestCase):
|
||||||
form.save()
|
form.save()
|
||||||
self.assertEqual(len(mail.outbox), 0)
|
self.assertEqual(len(mail.outbox), 0)
|
||||||
|
|
||||||
@override_settings(
|
|
||||||
TEMPLATE_LOADERS=('django.template.loaders.filesystem.Loader',),
|
|
||||||
TEMPLATE_DIRS=(
|
|
||||||
os.path.join(os.path.dirname(upath(__file__)), 'templates'),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
def test_save_plaintext_email(self):
|
def test_save_plaintext_email(self):
|
||||||
"""
|
"""
|
||||||
Test the PasswordResetForm.save() method with no html_email_template_name
|
Test the PasswordResetForm.save() method with no html_email_template_name
|
||||||
|
@ -477,12 +470,6 @@ class PasswordResetFormTest(TestCase):
|
||||||
self.assertEqual(message.get_all('to'), [email])
|
self.assertEqual(message.get_all('to'), [email])
|
||||||
self.assertTrue(re.match(r'^http://example.com/reset/[\w+/-]', message.get_payload()))
|
self.assertTrue(re.match(r'^http://example.com/reset/[\w+/-]', message.get_payload()))
|
||||||
|
|
||||||
@override_settings(
|
|
||||||
TEMPLATE_LOADERS=('django.template.loaders.filesystem.Loader',),
|
|
||||||
TEMPLATE_DIRS=(
|
|
||||||
os.path.join(os.path.dirname(upath(__file__)), 'templates'),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
def test_save_html_email_template_name(self):
|
def test_save_html_email_template_name(self):
|
||||||
"""
|
"""
|
||||||
Test the PasswordResetFOrm.save() method with html_email_template_name
|
Test the PasswordResetFOrm.save() method with html_email_template_name
|
||||||
|
|
Loading…
Reference in New Issue