-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RED] Create test and skeleton for SendRecoverPasswordEmail feature
- Loading branch information
1 parent
902840c
commit fa5c506
Showing
3 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
REGISTER_LINK = reverse('authentication:register') | ||
LOGIN_LINK = reverse('authentication:login') | ||
EMAIL_VERIFICATION_LINK = reverse('authentication:verify_email') | ||
RECOVER_PASSWORD_LINK = reverse('authentication:recover_password') | ||
|
||
class RegisterTest(TestCase): | ||
|
||
|
@@ -96,3 +97,36 @@ def test_valid_verification_token(self): | |
def test_invalid_verification_token(self): | ||
response = self.client.post((EMAIL_VERIFICATION_LINK), {'token': 'invalid token'}) | ||
self.assertEqual(response.status_code, 400) | ||
|
||
class SendRecoverPasswordEmailTest(TestCase): | ||
def setUp(self): | ||
self.client = APIClient() | ||
self.user = AppUser.objects.create_user(email='[email protected]',username='testuser',password='test') | ||
|
||
def test_sent_email_recover_password(self): | ||
response = self.client.post((RECOVER_PASSWORD_LINK), {'email':'[email protected]'}) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(len(mail.outbox), 1) | ||
self.assertEqual(mail.outbox[0].to, ['[email protected]']) | ||
|
||
def test_sent_wrong_email_recover_password(self): | ||
response = self.client.post((RECOVER_PASSWORD_LINK), {'email':'[email protected]'}) | ||
self.assertEqual(response.status_code, 400) | ||
|
||
def test_change_password(self): | ||
token = account_token.make_token(self.user) | ||
response = self.client.put((RECOVER_PASSWORD_LINK), | ||
{'email':'[email protected]', 'token': token, 'new_password':'newpass'}) | ||
self.assertEqual(response.status_code, 200) | ||
|
||
def test_change_password_wrong_email(self): | ||
token = account_token.make_token(self.user) | ||
response = self.client.put((RECOVER_PASSWORD_LINK), | ||
{'email':'[email protected]', 'token': token, 'new_password':'newpass'}) | ||
self.assertEqual(response.status_code, 400) | ||
|
||
def test_change_password_wrong_token(self): | ||
response = self.client.put((RECOVER_PASSWORD_LINK), | ||
{'email':'[email protected]', 'token': 'wrong token', 'new_password':'newpass'}) | ||
self.assertEqual(response.status_code, 400) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters