Skip to content
This repository has been archived by the owner on Nov 19, 2023. It is now read-only.

example of failing test on related_field #287

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
python -m venv .venv
source .venv/bin/activate
pip install wheel setuptools pip -U
poetry install --no-interaction --no-root --extras drf-spectacular --extras drf-yasg
poetry install --no-interaction --no-root --extras drf-spectacular --extras drf-yasg --extras djangorestframework-jsonapi
if: steps.cache-venv.outputs.cache-hit != 'true'
- run: |
source .venv/bin/activate
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ repos:
- types-PyYAML
- drf-yasg
- drf-spectacular

- djangorestframework-jsonapi
- repo: local
hooks:
- id: pylint
Expand Down
89 changes: 25 additions & 64 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ prance = "*"
pyYAML = "*"
drf-spectacular = { version = "*", optional = true }
drf-yasg = { version = "*", optional = true }
djangorestframework-jsonapi = { version = "*", optional = true }

[tool.poetry.extras]
drf-yasg = ["drf-yasg"]
drf-spectacular = ["drf-spectacular"]
djangorestframework-jsonapi = ["djangorestframework-jsonapi"]

[tool.poetry.dev-dependencies]
coverage = { extras = ["toml"], version = "^6" }
Expand Down
16 changes: 16 additions & 0 deletions test_project/api/views/pets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from rest_framework.response import Response
from rest_framework.status import HTTP_200_OK
from rest_framework_json_api.views import RelationshipView

if TYPE_CHECKING:
from rest_framework.request import Request



class PetOwnerRelationshipView(RelationshipView):
def post(self, request: Request, petId: int, relatedField: str) -> Response:
return Response({}, HTTP_200_OK)
8 changes: 7 additions & 1 deletion test_project/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.conf.urls.i18n import i18n_patterns
from django.urls import include, path
from django.urls import include, path, re_path
from drf_yasg import openapi
from drf_yasg.views import get_schema_view
from rest_framework import permissions, routers
Expand All @@ -11,6 +11,7 @@
from test_project.api.views.i18n import Languages
from test_project.api.views.items import Items
from test_project.api.views.names import EmptyNameViewSet, NamesRetrieveView, NameViewSet
from test_project.api.views.pets import PetOwnerRelationshipView
from test_project.api.views.products import Products
from test_project.api.views.snake_cased_response import SnakeCasedResponse
from test_project.api.views.trucks import BadTrucks, GoodTrucks
Expand All @@ -34,6 +35,11 @@
path("api/<str:version>/snake-case/", SnakeCasedResponse.as_view()),
# ^trailing slash is here on purpose
path("api/<str:version>/router_generated/", include(router.urls)),
re_path(
r"api/pet/(?P<petId>\d+)/relationships/(?P<relatedField>[-\w]+)",
PetOwnerRelationshipView.as_view(),
name="pet-owner-relation",
),
]

internationalised_urlpatterns = i18n_patterns(
Expand Down
Loading