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

Commit

Permalink
Run pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sondrelg committed Oct 31, 2021
1 parent 62472cc commit b27be05
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 23 deletions.
28 changes: 7 additions & 21 deletions test_project/api/views/products.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
2 changes: 1 addition & 1 deletion test_project/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion tests/test_loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}/"
)

0 comments on commit b27be05

Please sign in to comment.