MCPcopy Create free account
hub / github.com/encode/django-rest-framework / test_middle_offset

Method test_middle_offset

tests/test_pagination.py:467–490  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

465 }
466
467 def test_middle_offset(self):
468 request = Request(factory.get('/', {'limit': 5, 'offset': 10}))
469 queryset = self.paginate_queryset(request)
470 content = self.get_paginated_content(queryset)
471 context = self.get_html_context()
472 assert queryset == [11, 12, 13, 14, 15]
473 assert content == {
474 'results': [11, 12, 13, 14, 15],
475 'previous': 'http://testserver/?limit=5&offset=5',
476 'next': 'http://testserver/?limit=5&offset=15',
477 'count': 100
478 }
479 assert context == {
480 'previous_url': 'http://testserver/?limit=5&offset=5',
481 'next_url': 'http://testserver/?limit=5&offset=15',
482 'page_links': [
483 PageLink('http://testserver/?limit=5', 1, False, False),
484 PageLink('http://testserver/?limit=5&offset=5', 2, False, False),
485 PageLink('http://testserver/?limit=5&offset=10', 3, True, False),
486 PageLink('http://testserver/?limit=5&offset=15', 4, False, False),
487 PAGE_BREAK,
488 PageLink('http://testserver/?limit=5&offset=95', 20, False, False),
489 ]
490 }
491
492 def test_ending_offset(self):
493 request = Request(factory.get('/', {'limit': 5, 'offset': 95}))

Callers

nothing calls this directly

Calls 5

paginate_querysetMethod · 0.95
get_paginated_contentMethod · 0.95
get_html_contextMethod · 0.95
RequestClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected