diff --git a/test_project/api/views/products.py b/test_project/api/views/products.py index 5b1de26e..2281a375 100644 --- a/test_project/api/views/products.py +++ b/test_project/api/views/products.py @@ -1,3 +1,5 @@ +from typing import Dict + from rest_framework.request import Request from rest_framework.response import Response from rest_framework.status import HTTP_200_OK @@ -6,26 +8,10 @@ class Products(APIView): def get(self, request: Request, version: int, category_pk: int, subcategory_pk: int) -> Response: - products = { - 1: { - 1: {}, - 2: {}, - 3: {} - }, - 2: { - 1: {}, - 2: {}, - 3: {} - }, - 3: { - 1: {}, - 2: {}, - 3: {} - }, - 4: { - 1: {}, - 2: {}, - 3: {} - } + products: Dict[int, Dict] = { + 1: {1: {}, 2: {}, 3: {}}, + 2: {1: {}, 2: {}, 3: {}}, + 3: {1: {}, 2: {}, 3: {}}, + 4: {1: {}, 2: {}, 3: {}}, } return Response(products.get(category_pk, {}).get(subcategory_pk, {}), HTTP_200_OK) diff --git a/test_project/urls.py b/test_project/urls.py index 3105c46a..0df30d1c 100644 --- a/test_project/urls.py +++ b/test_project/urls.py @@ -11,10 +11,10 @@ from test_project.api.views.i18n import Languages from test_project.api.views.items import Items from test_project.api.views.names import NamesRetrieveView, NameViewSet +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 from test_project.api.views.vehicles import Vehicles -from test_project.api.views.products import Products router = routers.SimpleRouter() router.register(r"names", NameViewSet) diff --git a/tests/test_loaders.py b/tests/test_loaders.py index e89cc37c..b919aeba 100644 --- a/tests/test_loaders.py +++ b/tests/test_loaders.py @@ -48,4 +48,7 @@ def test_loader_resolve_path(loader): @pytest.mark.parametrize("loader", static_schema_loaders) def test_static_loader_resolve_nested_route(loader): - assert loader.resolve_path("/api/v1/categories/1/subcategories/1/", "get")[0] == "/api/{version}/categories/{category_pk}/subcategories/{subcategory_pk}/" + assert ( + loader.resolve_path("/api/v1/categories/1/subcategories/1/", "get")[0] + == "/api/{version}/categories/{category_pk}/subcategories/{subcategory_pk}/" + )