summaryrefslogtreecommitdiff
path: root/tests/auth_tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-01-11 18:12:06 -0500
committerTim Graham <timograham@gmail.com>2017-01-12 13:18:49 -0500
commit32265361279b3316f5bce8efa71f2049409461e3 (patch)
treeda9dd14255ea61f2a58ff24e048ace040ec33510 /tests/auth_tests
parent0b2e5da6ed946f10b4e0c1959f19d98449815715 (diff)
Split AuthTemplateTests into test methods.
Diffstat (limited to 'tests/auth_tests')
-rw-r--r--tests/auth_tests/test_templates.py29
1 files changed, 19 insertions, 10 deletions
diff --git a/tests/auth_tests/test_templates.py b/tests/auth_tests/test_templates.py
index 5bcc5e3672..9414f8b299 100644
--- a/tests/auth_tests/test_templates.py
+++ b/tests/auth_tests/test_templates.py
@@ -13,42 +13,51 @@ from django.utils.http import urlsafe_base64_encode
@override_settings(ROOT_URLCONF='auth_tests.urls')
class AuthTemplateTests(TestCase):
- def test_titles(self):
+ @classmethod
+ def setUpTestData(cls):
rf = RequestFactory()
user = User.objects.create_user('jsmith', 'jsmith@example.com', 'pass')
user = authenticate(username=user.username, password='pass')
request = rf.get('/somepath/')
request.user = user
+ cls.user, cls.request = user, request
- response = PasswordResetView.as_view(success_url='dummy/')(request)
+ def test_PasswordResetView(self):
+ response = PasswordResetView.as_view(success_url='dummy/')(self.request)
self.assertContains(response, '<title>Password reset</title>')
self.assertContains(response, '<h1>Password reset</h1>')
- response = PasswordResetDoneView.as_view()(request)
+ def test_PasswordResetDoneView(self):
+ response = PasswordResetDoneView.as_view()(self.request)
self.assertContains(response, '<title>Password reset sent</title>')
self.assertContains(response, '<h1>Password reset sent</h1>')
+ def test_PasswordResetConfirmView_invalid_token(self):
# PasswordResetConfirmView invalid token
- response = PasswordResetConfirmView.as_view(success_url='dummy/')(request, uidb64='Bad', token='Bad')
+ response = PasswordResetConfirmView.as_view(success_url='dummy/')(self.request, uidb64='Bad', token='Bad')
self.assertContains(response, '<title>Password reset unsuccessful</title>')
self.assertContains(response, '<h1>Password reset unsuccessful</h1>')
+ def test_PasswordResetConfirmView_valid_token(self):
# PasswordResetConfirmView valid token
default_token_generator = PasswordResetTokenGenerator()
- token = default_token_generator.make_token(user)
- uidb64 = force_text(urlsafe_base64_encode(force_bytes(user.pk)))
- response = PasswordResetConfirmView.as_view(success_url='dummy/')(request, uidb64=uidb64, token=token)
+ token = default_token_generator.make_token(self.user)
+ uidb64 = force_text(urlsafe_base64_encode(force_bytes(self.user.pk)))
+ response = PasswordResetConfirmView.as_view(success_url='dummy/')(self.request, uidb64=uidb64, token=token)
self.assertContains(response, '<title>Enter new password</title>')
self.assertContains(response, '<h1>Enter new password</h1>')
- response = PasswordResetCompleteView.as_view()(request)
+ def test_PasswordResetCompleteView(self):
+ response = PasswordResetCompleteView.as_view()(self.request)
self.assertContains(response, '<title>Password reset complete</title>')
self.assertContains(response, '<h1>Password reset complete</h1>')
- response = PasswordChangeView.as_view(success_url='dummy/')(request)
+ def test_PasswordResetChangeView(self):
+ response = PasswordChangeView.as_view(success_url='dummy/')(self.request)
self.assertContains(response, '<title>Password change</title>')
self.assertContains(response, '<h1>Password change</h1>')
- response = PasswordChangeDoneView.as_view()(request)
+ def test_PasswordChangeDoneView(self):
+ response = PasswordChangeDoneView.as_view()(self.request)
self.assertContains(response, '<title>Password change successful</title>')
self.assertContains(response, '<h1>Password change successful</h1>')