MCPcopy
hub / github.com/django/django / check_indexes

Method check_indexes

tests/pagination/tests.py:290–313  ·  view source on GitHub ↗

Helper method that instantiates a Paginator object from the passed params and then checks that the start and end indexes of the passed page_num match those given as a 2-tuple in indexes.

(self, params, page_num, indexes)

Source from the content-addressed store, hash-verified

288 await AsyncPaginator(TypeErrorContainer(), 10).acount()
289
290 def check_indexes(self, params, page_num, indexes):
291 """
292 Helper method that instantiates a Paginator object from the passed
293 params and then checks that the start and end indexes of the passed
294 page_num match those given as a 2-tuple in indexes.
295 """
296 paginator = Paginator(*params)
297 if page_num == "first":
298 page_num = 1
299 elif page_num == "last":
300 page_num = paginator.num_pages
301 page = paginator.page(page_num)
302 start, end = indexes
303 msg = "For %s of page %s, expected %s but got %s. Paginator parameters were: %s"
304 self.assertEqual(
305 start,
306 page.start_index(),
307 msg % ("start index", page_num, start, page.start_index(), params),
308 )
309 self.assertEqual(
310 end,
311 page.end_index(),
312 msg % ("end index", page_num, end, page.end_index(), params),
313 )
314
315 async def check_indexes_async(self, params, page_num, indexes):
316 """See check_indexes."""

Callers 1

test_page_indexesMethod · 0.95

Calls 4

pageMethod · 0.95
PaginatorClass · 0.90
start_indexMethod · 0.80
end_indexMethod · 0.80

Tested by

no test coverage detected