-
Notifications
You must be signed in to change notification settings - Fork 11
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
bf9d0d4
commit 15c83ce
Showing
6 changed files
with
37 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
from django.urls import path, include | ||
from custom_auth import views as custom_auth_views | ||
|
||
urlpatterns = [ | ||
] |
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 |
---|---|---|
@@ -1,14 +0,0 @@ | ||
import pytest | ||
|
||
from custom_auth.models import User | ||
|
||
|
||
@pytest.fixture | ||
def user(db, django_user_model): | ||
return django_user_model.objects.create( | ||
first_name="Alice", | ||
last_name="Nolastname", | ||
email="[email protected]", | ||
password="nfpt30x49q2obt9" | ||
) | ||
|
||
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 |
---|---|---|
@@ -1,33 +1,47 @@ | ||
import pytest | ||
from django.core import mail | ||
from pytest_django.asserts import assertRedirects, assertTemplateUsed | ||
from tests.conftest import user | ||
|
||
|
||
@pytest.fixture | ||
def user(db, django_user_model): | ||
return django_user_model.objects.create( | ||
first_name="Alice", | ||
last_name="Nolastname", | ||
email="[email protected]", | ||
password="nfpt30x49q2obt9" | ||
) | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_register(client): | ||
response = client.post( | ||
"/accounts/signup/", | ||
dict(email="[email protected]", | ||
last_name="Rabbit", first_name="White", | ||
password1="FNEYghfr", | ||
password2="FNEYghfr"), | ||
format="text/html") | ||
dict( | ||
email="[email protected]", | ||
last_name="Rabbit", | ||
first_name="White", | ||
password1="FNEYghfr", | ||
password2="FNEYghfr", | ||
), | ||
format="text/html", | ||
) | ||
assertRedirects( | ||
response, | ||
"/accounts/confirm-email/", | ||
status_code=302, | ||
target_status_code=200, | ||
fetch_redirect_response=True | ||
fetch_redirect_response=True, | ||
) | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_get_register_page(client): | ||
response = client.get("/accounts/signup/") | ||
assert response.status_code == 200 | ||
assert response.status_code == 200 | ||
assertTemplateUsed(response, "account/signup.html") | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_valid_template_for_forgotten_password(client): | ||
response = client.get("/accounts/password/reset/") | ||
|
@@ -39,28 +53,30 @@ def test_valid_email_sending_for_forgotten_password(user, client): | |
response = client.post( | ||
"/accounts/password/reset/", | ||
dict(email=user.email), | ||
format="text/html" | ||
format="text/html", | ||
) | ||
assertRedirects( | ||
response, | ||
"/accounts/password/reset/done/", | ||
status_code=302, | ||
target_status_code=200, | ||
fetch_redirect_response=True | ||
fetch_redirect_response=True, | ||
) | ||
assert mail.outbox[0].to == [user.email] | ||
assert len(mail.outbox) == 1 | ||
|
||
assert len(mail.outbox) == 1 | ||
|
||
|
||
def test_valid_url_to_reset_password(user, client): | ||
client.post("/accounts/password/reset/", | ||
dict(email=user.email), | ||
format="text/html") | ||
client.post( | ||
"/accounts/password/reset/", | ||
dict(email=user.email), | ||
format="text/html", | ||
) | ||
email_lines = mail.outbox[0].body.splitlines() | ||
url = email_lines[6] | ||
re = client.post( | ||
url, | ||
dict(password1="FNEYghfr",password2="FNEYghfr"), | ||
format="text/html") | ||
dict(password1="FNEYghfr", password2="FNEYghfr"), | ||
format="text/html", | ||
) | ||
assert re.status_code == 200 |