Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Contributor frontend 4 #133

Merged
merged 7 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions codeforlife/tests/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,17 @@ class APIClient(_APIClient, t.Generic[RequestUser]):

_test_case: "APITestCase[RequestUser]"

def __init__(self, enforce_csrf_checks: bool = False, **defaults):
super().__init__(enforce_csrf_checks, **defaults)
def __init__(
self,
enforce_csrf_checks: bool = False,
raise_request_exception=False,
**defaults,
):
super().__init__(
enforce_csrf_checks,
raise_request_exception=raise_request_exception,
**defaults,
)

self.request_factory = APIRequestFactory(
self.get_request_user_class(),
Expand Down Expand Up @@ -329,7 +338,7 @@ def generic(
assert status_code_assertion(
status_code
), f"Unexpected status code: {status_code}." + (
"\nValidation errors:: "
"\nValidation errors: "
+ json.dumps(
# pylint: disable-next=no-member
response.json(), # type: ignore[attr-defined]
Expand Down
7 changes: 7 additions & 0 deletions codeforlife/urls/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
© Ocado Group
Created on 16/09/2024 at 15:23:05(+01:00).
"""

from .handlers import handler400, handler403, handler404, handler500
from .patterns import UrlPatterns, get_urlpatterns

Check warning on line 7 in codeforlife/urls/__init__.py

View check run for this annotation

Codecov / codecov/patch

codeforlife/urls/__init__.py#L6-L7

Added lines #L6 - L7 were not covered by tests
23 changes: 23 additions & 0 deletions codeforlife/urls/handlers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
© Ocado Group
Created on 16/09/2024 at 15:19:54(+01:00).

Custom error handlers which override django's default behavior to render a
template.

https://docs.djangoproject.com/en/3.2/ref/urls/#module-django.conf.urls
"""

from django.http import (

Check warning on line 11 in codeforlife/urls/handlers.py

View check run for this annotation

Codecov / codecov/patch

codeforlife/urls/handlers.py#L11

Added line #L11 was not covered by tests
HttpResponseBadRequest,
HttpResponseForbidden,
HttpResponseNotFound,
HttpResponseServerError,
)

# pylint: disable=unnecessary-lambda-assignment
handler400 = lambda request, template: HttpResponseBadRequest()
handler403 = lambda request, template: HttpResponseForbidden()
handler404 = lambda request, template: HttpResponseNotFound()
handler500 = lambda request: HttpResponseServerError()

Check warning on line 22 in codeforlife/urls/handlers.py

View check run for this annotation

Codecov / codecov/patch

codeforlife/urls/handlers.py#L19-L22

Added lines #L19 - L22 were not covered by tests
# pylint: enable=unnecessary-lambda-assignment
4 changes: 2 additions & 2 deletions codeforlife/urls.py → codeforlife/urls/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from django.urls import URLPattern, URLResolver, include, path, re_path
from rest_framework import status

from .settings import SERVICE_IS_ROOT, SERVICE_NAME
from .views import CsrfCookieView, LogoutView
from ..settings import SERVICE_IS_ROOT, SERVICE_NAME
from ..views import CsrfCookieView, LogoutView

Check warning on line 14 in codeforlife/urls/patterns.py

View check run for this annotation

Codecov / codecov/patch

codeforlife/urls/patterns.py#L13-L14

Added lines #L13 - L14 were not covered by tests

UrlPatterns = t.List[t.Union[URLResolver, URLPattern]]

Expand Down