Commit 6bf1a1ff authored by Chris Lamb's avatar Chris Lamb
Browse files

Factor out registration tests into an assertRegister utility (re. #18)

parent 15eacc17
from django.conf import settings
from django.contrib.auth import get_user_model
from freenodejobs.utils.test import TestCase
UserModel = get_user_model()
class RegistrationTests(TestCase):
def assertRegister(self):
email = 'new@email.com'
self.assertPOST({
'email': 'new@email.com',
'password1': 'newpassword',
'password2': 'newpassword',
}, 'registration:view', login=None)
return UserModel.objects.get(email=email)
def test_logged_in(self):
response = self.assertGET(302, 'registration:view')
self.assertRedirectsToUrl(response, settings.LOGIN_REDIRECT_URL)
......@@ -12,11 +26,9 @@ class RegistrationTests(TestCase):
self.assertGET(200, 'registration:view', login=None)
def test_POST(self):
self.assertPOST({
'email': 'new@email.com',
'password1': 'newpassword',
'password2': 'newpassword',
}, 'registration:view', login=None)
user = self.assertRegister()
self.assertFalse(user.email_validated)
def test_POST_duplicate_email(self):
response = self.assertPOST({
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment