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

Method test_first_offset

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

Source from the content-addressed store, hash-verified

441 }
442
443 def test_first_offset(self):
444 request = Request(factory.get('/', {'limit': 5, 'offset': 5}))
445 queryset = self.paginate_queryset(request)
446 content = self.get_paginated_content(queryset)
447 context = self.get_html_context()
448 assert queryset == [6, 7, 8, 9, 10]
449 assert content == {
450 'results': [6, 7, 8, 9, 10],
451 'previous': 'http://testserver/?limit=5',
452 'next': 'http://testserver/?limit=5&offset=10',
453 'count': 100
454 }
455 assert context == {
456 'previous_url': 'http://testserver/?limit=5',
457 'next_url': 'http://testserver/?limit=5&offset=10',
458 'page_links': [
459 PageLink('http://testserver/?limit=5', 1, False, False),
460 PageLink('http://testserver/?limit=5&offset=5', 2, True, False),
461 PageLink('http://testserver/?limit=5&offset=10', 3, False, False),
462 PAGE_BREAK,
463 PageLink('http://testserver/?limit=5&offset=95', 20, False, False),
464 ]
465 }
466
467 def test_middle_offset(self):
468 request = Request(factory.get('/', {'limit': 5, 'offset': 10}))

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