When the offset is not a multiple of the limit we get some edge cases: * The first page should still be offset zero. * We may end up displaying an extra page in the pagination control.
(self)
| 412 | assert queryset is None |
| 413 | |
| 414 | def test_single_offset(self): |
| 415 | """ |
| 416 | When the offset is not a multiple of the limit we get some edge cases: |
| 417 | * The first page should still be offset zero. |
| 418 | * We may end up displaying an extra page in the pagination control. |
| 419 | """ |
| 420 | request = Request(factory.get('/', {'limit': 5, 'offset': 1})) |
| 421 | queryset = self.paginate_queryset(request) |
| 422 | content = self.get_paginated_content(queryset) |
| 423 | context = self.get_html_context() |
| 424 | assert queryset == [2, 3, 4, 5, 6] |
| 425 | assert content == { |
| 426 | 'results': [2, 3, 4, 5, 6], |
| 427 | 'previous': 'http://testserver/?limit=5', |
| 428 | 'next': 'http://testserver/?limit=5&offset=6', |
| 429 | 'count': 100 |
| 430 | } |
| 431 | assert context == { |
| 432 | 'previous_url': 'http://testserver/?limit=5', |
| 433 | 'next_url': 'http://testserver/?limit=5&offset=6', |
| 434 | 'page_links': [ |
| 435 | PageLink('http://testserver/?limit=5', 1, False, False), |
| 436 | PageLink('http://testserver/?limit=5&offset=1', 2, True, False), |
| 437 | PageLink('http://testserver/?limit=5&offset=6', 3, False, False), |
| 438 | PAGE_BREAK, |
| 439 | PageLink('http://testserver/?limit=5&offset=96', 21, False, False), |
| 440 | ] |
| 441 | } |
| 442 | |
| 443 | def test_first_offset(self): |
| 444 | request = Request(factory.get('/', {'limit': 5, 'offset': 5})) |
nothing calls this directly
no test coverage detected