Skip to content

Commit

Permalink
Add tests to verify email for ResendConfirmationEmail view
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Etienne committed Jan 26, 2015
1 parent e9818cd commit 82fb2b3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions user_management/api/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@ class ResendConfirmationEmailTest(APIRequestTestCase):
view_class = views.ResendConfirmationEmail

def test_post(self):
"""Assert user can request a new confirmation email."""
user = UserFactory.create()
data = {'email': user.email}
request = self.create_request('post', auth=False, data=data)
Expand All @@ -854,7 +855,27 @@ def test_post(self):
msg=response.data,
)

def test_post_unknown_email(self):
"""Assert unknown email raises an error."""
data = {'email': 'theman@theiron.mask'}
request = self.create_request('post', auth=False, data=data)
view = self.view_class.as_view()
response = view(request)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertIn('email', response.data)

def test_post_email_already_verified(self):
"""Assert email already verified does not trigger another email."""
user = UserFactory.create(email_verification_required=False)
data = {'email': user.email}
request = self.create_request('post', auth=False, data=data)
view = self.view_class.as_view()
response = view(request)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertIn('email', response.data)

def test_send_email(self):
"""Assert user can receive a new confirmation email."""
user = UserFactory.create()
data = {'email': user.email}
request = self.create_request('post', auth=False, data=data)
Expand Down

0 comments on commit 82fb2b3

Please sign in to comment.