@@ -33,22 +33,22 @@ def paginate_queryset(self, items, request, **params):
3333class SomeAPIController :
3434 @route .get ("/items_1" )
3535 @paginate # WITHOUT brackets (should use default pagination)
36- def items_1 (self , ** kwargs ):
36+ def items_1 (self ):
3737 return ITEMS
3838
3939 @route .get ("/items_2" )
4040 @paginate () # with brackets (should use default pagination)
41- def items_2 (self , someparam : int = 0 , ** kwargs ):
41+ def items_2 (self , someparam : int = 0 ):
4242 # also having custom param `someparam` - that should not be lost
4343 return ITEMS
4444
4545 @route .get ("/items_3" )
46- @paginate (CustomPagination )
46+ @paginate (CustomPagination , pass_parameter = "pass_kwargs" )
4747 def items_3 (self , ** kwargs ):
4848 return ITEMS
4949
5050 @route .get ("/items_4" )
51- @paginate (PageNumberPaginationExtra , page_size = 10 )
51+ @paginate (PageNumberPaginationExtra , page_size = 10 , pass_parameter = "pass_kwargs" )
5252 def items_4 (self , ** kwargs ):
5353 return ITEMS
5454
@@ -72,7 +72,7 @@ def test_paginator_operation_used(self):
7272 SomeAPIController , lambda member : isinstance (member , RouteFunction )
7373 )
7474 }
75- has_kwargs = ("items_1" , " items_3" , "items_4" )
75+ has_kwargs = ("items_3" , "items_4" )
7676 for name , route_function in some_api_route_functions .items ():
7777 assert hasattr (route_function .as_view , "paginator_operation" )
7878 paginator_operation = route_function .as_view .paginator_operation
@@ -82,7 +82,8 @@ def test_paginator_operation_used(self):
8282
8383 def test_case1 (self ):
8484 response = client .get ("/items_1?limit=10" ).json ()
85- assert response == ITEMS [:10 ]
85+ assert response .get ("items" )
86+ assert response ["items" ] == ITEMS [:10 ]
8687
8788 schema = api .get_openapi_schema ()["paths" ]["/api/items_1" ]["get" ]
8889 # print(schema)
@@ -113,7 +114,8 @@ def test_case1(self):
113114
114115 def test_case2 (self ):
115116 response = client .get ("/items_2?limit=10" ).json ()
116- assert response == ITEMS [:10 ]
117+ assert response .get ("items" )
118+ assert response ["items" ] == ITEMS [:10 ]
117119
118120 schema = api .get_openapi_schema ()["paths" ]["/api/items_2" ]["get" ]
119121 # print(schema["parameters"])
@@ -199,7 +201,8 @@ def test_case4(self):
199201
200202 def test_case5 (self ):
201203 response = client .get ("/items_5?page=2" ).json ()
202- assert response == ITEMS [10 :20 ]
204+ assert response .get ("items" )
205+ assert response ["items" ] == ITEMS [10 :20 ]
203206
204207 schema = api .get_openapi_schema ()["paths" ]["/api/items_5" ]["get" ]
205208 # print(schema)
@@ -232,17 +235,19 @@ async def items_1(self, **kwargs):
232235
233236 @route .get ("/items_2" )
234237 @paginate () # with brackets (should use default pagination)
235- async def items_2 (self , someparam : int = 0 , ** kwargs ):
238+ async def items_2 (self , someparam : int = 0 ):
236239 # also having custom param `someparam` - that should not be lost
237240 return ITEMS
238241
239242 @route .get ("/items_3" )
240- @paginate (CustomPagination )
243+ @paginate (CustomPagination , pass_parameter = "pass_kwargs" )
241244 async def items_3 (self , ** kwargs ):
242245 return ITEMS
243246
244247 @route .get ("/items_4" )
245- @paginate (PageNumberPaginationExtra , page_size = 10 )
248+ @paginate (
249+ PageNumberPaginationExtra , page_size = 10 , pass_parameter = "pass_kwargs"
250+ )
246251 async def items_4 (self , ** kwargs ):
247252 return ITEMS
248253
@@ -263,7 +268,7 @@ async def test_paginator_operation_used(self):
263268 lambda member : isinstance (member , RouteFunction ),
264269 )
265270 }
266- has_kwargs = ("items_1" , " items_3" , "items_4" )
271+ has_kwargs = ("items_3" , "items_4" )
267272 for name , route_function in some_api_route_functions .items ():
268273 assert hasattr (route_function .as_view , "paginator_operation" )
269274 paginator_operation = route_function .as_view .paginator_operation
@@ -273,7 +278,9 @@ async def test_paginator_operation_used(self):
273278
274279 async def test_case1 (self ):
275280 response = await self .client .get ("/items_1?limit=10" )
276- assert response .json () == ITEMS [:10 ]
281+ data = response .json ()
282+ assert data .get ("items" )
283+ assert data ["items" ] == ITEMS [:10 ]
277284
278285 schema = self .api_async .get_openapi_schema ()["paths" ]["/api/items_1" ]["get" ]
279286 # print(schema)
@@ -304,7 +311,9 @@ async def test_case1(self):
304311
305312 async def test_case2 (self ):
306313 response = await self .client .get ("/items_2?limit=10" )
307- assert response .json () == ITEMS [:10 ]
314+ data = response .json ()
315+ assert data .get ("items" )
316+ assert data ["items" ] == ITEMS [:10 ]
308317
309318 async def test_case3 (self ):
310319 response = await self .client .get ("/items_3?skip=5" )
@@ -320,4 +329,6 @@ async def test_case4(self):
320329
321330 async def test_case5 (self ):
322331 response = await self .client .get ("/items_5?page=2" )
323- assert response .json () == ITEMS [10 :20 ]
332+ data = response .json ()
333+ assert data .get ("items" )
334+ assert data ["items" ] == ITEMS [10 :20 ]
0 commit comments