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

Method test_ending_offset

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

Source from the content-addressed store, hash-verified

490 }
491
492 def test_ending_offset(self):
493 request = Request(factory.get('/', {'limit': 5, 'offset': 95}))
494 queryset = self.paginate_queryset(request)
495 content = self.get_paginated_content(queryset)
496 context = self.get_html_context()
497 assert queryset == [96, 97, 98, 99, 100]
498 assert content == {
499 'results': [96, 97, 98, 99, 100],
500 'previous': 'http://testserver/?limit=5&offset=90',
501 'next': None,
502 'count': 100
503 }
504 assert context == {
505 'previous_url': 'http://testserver/?limit=5&offset=90',
506 'next_url': None,
507 'page_links': [
508 PageLink('http://testserver/?limit=5', 1, False, False),
509 PAGE_BREAK,
510 PageLink('http://testserver/?limit=5&offset=85', 18, False, False),
511 PageLink('http://testserver/?limit=5&offset=90', 19, False, False),
512 PageLink('http://testserver/?limit=5&offset=95', 20, True, False),
513 ]
514 }
515
516 def test_erroneous_offset(self):
517 request = Request(factory.get('/', {'limit': 5, 'offset': 1000}))

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