Skip to content

Commit

Permalink
Feature(Reset password): Add unittests
Browse files Browse the repository at this point in the history
- Add test for email verification after signup
[Feature #161255355]
  • Loading branch information
KE-C02QF4HNFVH3 authored and KE-C02QF4HNFVH3 committed Nov 4, 2018
1 parent 8861aed commit 3778140
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions authors/apps/authentication/tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,16 @@ def test_missing_password(self):
self.missing_password,
format="json")
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

def test_verify_email(self):
'''Test verify email'''
response = self.client.post(
self.SIGN_UP_URL,
self.user_data,
format="json")
content = json.loads(response.content)
token = content['user']['token']
VERIFY_URL = '/api/users/verify/{}/'.format(token)
response = self.client.get(VERIFY_URL)
self.assertEqual(json.loads(response.content), 'Email Confirmed Successfully')
self.assertEqual(response.status_code, status.HTTP_200_OK)
2 changes: 1 addition & 1 deletion authors/apps/authentication/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def post(self, request):

send_mail(subject, '', from_email, to_email, html_message=message)

return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(dict(email=user_email, username=user_name, token=token), status=status.HTTP_201_CREATED)

class LoginAPIView(CreateAPIView):
permission_classes = (AllowAny,)
Expand Down

0 comments on commit 3778140

Please sign in to comment.