-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1550 from gustavomm19/email-verification
Make endpoint to verify if email is verified
- Loading branch information
Showing
3 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
breathecode/authenticate/tests/urls/v1/tests_email_verification.py
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
""" | ||
Test cases for /emailvalidation | ||
""" | ||
|
||
import pytest | ||
from django.urls.base import reverse_lazy | ||
from rest_framework import status | ||
from rest_framework.test import APIClient | ||
from linked_services.django.actions import reset_app_cache | ||
|
||
from breathecode.tests.mixins.breathecode_mixin.breathecode import Breathecode | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def setup(db): | ||
reset_app_cache() | ||
yield | ||
|
||
|
||
def test_email_verification_no_user(bc: Breathecode, client: APIClient): | ||
email = "[email protected]" | ||
|
||
url = reverse_lazy("authenticate:email_verification", kwargs={"email": email}) | ||
response = client.get(url) | ||
|
||
json = response.json() | ||
expected = {"detail": "email-not-found", "status_code": 400} | ||
|
||
assert json == expected | ||
assert response.status_code == status.HTTP_400_BAD_REQUEST | ||
|
||
|
||
def test_email_verification_not_validated(bc: Breathecode, client: APIClient): | ||
email = "[email protected]" | ||
|
||
model = bc.database.create(user={"email": email}, user_invite={"email": email, "is_email_validated": False}) | ||
|
||
url = reverse_lazy("authenticate:email_verification", kwargs={"email": email}) | ||
response = client.get(url) | ||
|
||
json = response.json() | ||
expected = {"detail": "email-not-validated", "status_code": 400} | ||
|
||
assert json == expected | ||
assert response.status_code == status.HTTP_400_BAD_REQUEST | ||
|
||
|
||
def test_email_verification(bc: Breathecode, client: APIClient): | ||
email = "[email protected]" | ||
model = bc.database.create(user={"email": email}) | ||
|
||
url = reverse_lazy("authenticate:email_verification", kwargs={"email": email}) | ||
response = client.get(url) | ||
|
||
assert response.status_code == status.HTTP_204_NO_CONTENT |
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