Skip to content

Commit

Permalink
format code :(
Browse files Browse the repository at this point in the history
  • Loading branch information
anjaniacatus committed Dec 19, 2024
1 parent bf9d0d4 commit 15c83ce
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 39 deletions.
5 changes: 3 additions & 2 deletions core/settings_dev.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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"
3 changes: 1 addition & 2 deletions core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 0 additions & 1 deletion custom_auth/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django import forms
from allauth.account.forms import SignupForm
from custom_auth.models import User


class CustomSignupForm(SignupForm):
Expand Down
3 changes: 0 additions & 3 deletions custom_auth/urls.py
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 = [
]
14 changes: 0 additions & 14 deletions tests/conftest.py
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"
)

50 changes: 33 additions & 17 deletions tests/unit_tests/test_authentification.py
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/")
Expand All @@ -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

0 comments on commit 15c83ce

Please sign in to comment.