diff --git a/core/settings_dev.py b/core/settings_dev.py index 075805c..071a78e 100644 --- a/core/settings_dev.py +++ b/core/settings_dev.py @@ -1,4 +1,5 @@ from .settings_base import * # noqa: F403 +from .settings_base import BASE_DIR import dj_database_url SECRET_KEY = "not really a secret" @@ -34,5 +35,5 @@ ) } -EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend' -EMAIL_FILE_PATH = BASE_DIR / 'emails' +EMAIL_BACKEND = "django.core.mail.backends.filebased.EmailBackend" +EMAIL_FILE_PATH = BASE_DIR / "emails" diff --git a/core/urls.py b/core/urls.py index 19a5404..f6970b7 100644 --- a/core/urls.py +++ b/core/urls.py @@ -16,11 +16,10 @@ from django.contrib import admin from django.urls import path, include -from django.contrib.auth import views as auth_views urlpatterns = [ - path("", include("website.urls")), + path("", include("website.urls")), path("accounts/", include("allauth.urls")), path("proposals/", include("proposals.urls")), path("admin/", admin.site.urls), diff --git a/custom_auth/forms.py b/custom_auth/forms.py index 5190106..2a4ef0f 100644 --- a/custom_auth/forms.py +++ b/custom_auth/forms.py @@ -1,6 +1,5 @@ from django import forms from allauth.account.forms import SignupForm -from custom_auth.models import User class CustomSignupForm(SignupForm): diff --git a/custom_auth/urls.py b/custom_auth/urls.py index 4fdbb9c..1170d21 100644 --- a/custom_auth/urls.py +++ b/custom_auth/urls.py @@ -1,5 +1,2 @@ -from django.urls import path, include -from custom_auth import views as custom_auth_views - urlpatterns = [ ] diff --git a/tests/conftest.py b/tests/conftest.py index 4321f02..e69de29 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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="alice@wonderland.com", - password="nfpt30x49q2obt9" - ) - diff --git a/tests/unit_tests/test_authentification.py b/tests/unit_tests/test_authentification.py index a3a146a..d115b49 100644 --- a/tests/unit_tests/test_authentification.py +++ b/tests/unit_tests/test_authentification.py @@ -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="alice@wonderland.com", + password="nfpt30x49q2obt9" + ) @pytest.mark.django_db def test_register(client): response = client.post( "/accounts/signup/", - dict(email="rabbit.white@wonderland.com", - last_name="Rabbit", first_name="White", - password1="FNEYghfr", - password2="FNEYghfr"), - format="text/html") + dict( + email="rabbit.white@wonderland.com", + 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