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

Commit

Permalink
example of failing tests on content type
Browse files Browse the repository at this point in the history
  • Loading branch information
Darragh Duffy committed Nov 24, 2022
1 parent 20e0563 commit d05bf91
Show file tree
Hide file tree
Showing 5 changed files with 854 additions and 2 deletions.
2 changes: 1 addition & 1 deletion openapi_tester/schema_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def get_response_schema_section(self, response: Response) -> dict[str, Any]:
r"^application\/.*json$",
"\n\nNo `application/json` responses documented for method: "
f"{response_method}, path: {parameterized_path}",
use_regex=True
use_regex=True,
)
return self.get_key_value(json_object, "schema")

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.views import APIView

if TYPE_CHECKING:
from rest_framework.request import Request


class Pet(APIView):
def get(self, request: Request, petId: int) -> Response:
pet = {"name": "doggie", "category": {"id": 1, "name": "Dogs"}, "photoUrls": [], "status": "available"}
return Response(pet, HTTP_200_OK)
4 changes: 3 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 Pet
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,7 @@
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+)", Pet.as_view(), name="get-pet"),
]

internationalised_urlpatterns = i18n_patterns(
Expand Down
Loading

0 comments on commit d05bf91

Please sign in to comment.