-
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.
Merge branch 'main' of github.com:wildjames/todoqueue
- Loading branch information
Showing
58 changed files
with
642 additions
and
345 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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
from rest_framework_simplejwt.tokens import RefreshToken | ||
|
||
from logging import getLogger | ||
|
||
logger = getLogger(__name__) | ||
|
||
from .serializers import CustomUserSerializer | ||
|
@@ -173,44 +174,46 @@ def test_complete_forgot_password(self): | |
) | ||
|
||
def test_register_existing_email(self): | ||
url = reverse('register') | ||
url = reverse("register") | ||
data = { | ||
"email": "[email protected]", | ||
"username": "someotheruser", | ||
"password": "somepass" | ||
"password": "somepass", | ||
} | ||
response = self.client.post(url, data, format='json') | ||
response = self.client.post(url, data, format="json") | ||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
self.assertIn('detail', response.data) | ||
self.assertEqual(response.data['detail'], 'User with this email already exists.') | ||
self.assertIn("detail", response.data) | ||
self.assertEqual( | ||
response.data["detail"], "User with this email already exists." | ||
) | ||
|
||
def test_failed_login(self): | ||
url = reverse('token_obtain_pair') | ||
data = { | ||
"email": "[email protected]", | ||
"password": "wrongpassword" | ||
} | ||
response = self.client.post(url, data, format='json') | ||
url = reverse("token_obtain_pair") | ||
data = {"email": "[email protected]", "password": "wrongpassword"} | ||
response = self.client.post(url, data, format="json") | ||
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) | ||
self.assertEqual(response.data["detail"], "No active account found with the given credentials") | ||
self.assertEqual( | ||
response.data["detail"], | ||
"No active account found with the given credentials", | ||
) | ||
|
||
def test_custom_user_viewset_list(self): | ||
# First get a token for the user | ||
token = RefreshToken.for_user(self.user) | ||
self.client.credentials(HTTP_AUTHORIZATION=f'Bearer {token.access_token}') | ||
self.client.credentials(HTTP_AUTHORIZATION=f"Bearer {token.access_token}") | ||
|
||
# Now, retrieve list of users | ||
url = reverse('customuser-list') | ||
response = self.client.get(url, format='json') | ||
url = reverse("customuser-list") | ||
response = self.client.get(url, format="json") | ||
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) | ||
|
||
def test_custom_user_viewset_retrieve(self): | ||
# First get a token for the user | ||
token = RefreshToken.for_user(self.user) | ||
self.client.credentials(HTTP_AUTHORIZATION=f'Bearer {token.access_token}') | ||
self.client.credentials(HTTP_AUTHORIZATION=f"Bearer {token.access_token}") | ||
|
||
# Now, retrieve the user's own details | ||
url = reverse('customuser-detail', args=[self.user.id]) | ||
response = self.client.get(url, format='json') | ||
url = reverse("customuser-detail", args=[self.user.id]) | ||
response = self.client.get(url, format="json") | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertEqual(response.data['email'], self.user.email) | ||
self.assertEqual(response.data["email"], self.user.email) |
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
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
Oops, something went wrong.