-
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.
- Loading branch information
1 parent
118b98c
commit 490ac35
Showing
3 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
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,64 @@ | ||
""" | ||
Test cases for /emailvalidation | ||
""" | ||
|
||
import re | ||
import urllib | ||
from unittest import mock | ||
|
||
import capyc.pytest as capy | ||
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 | ||
|
||
import staging.pytest as staging | ||
from breathecode.authenticate.tests.mocks.mocks import FakeResponse | ||
from breathecode.tests.mixins.breathecode_mixin.breathecode import Breathecode | ||
|
||
from ...mocks import GithubRequestsMock | ||
|
||
|
||
@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