Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added test for limit=0 when using LimitOffsetPagination
  • Loading branch information
nhorelik committed Sep 24, 2015
commit 0429201ddb9276b5e47a1eb48196f4f9c33eac55
15 changes: 15 additions & 0 deletions tests/test_pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,21 @@ def test_max_limit(self):
assert content.get('next') == next_url
assert content.get('previous') == prev_url

def test_limit_is_zero(self):
"""
A limit of zero should produce an empty queryset without Exceptions and
otherwise favor the defaults.
"""
request = Request(factory.get('/', {'limit': '0', 'offset': 0}))
queryset = self.paginate_queryset(request)
content = self.get_paginated_content(queryset)
context = self.get_html_context()
next_limit = self.pagination.default_limit
next_offset = self.pagination.default_limit
next_url = 'http://testserver/?limit={0}&offset={1}'.format(next_limit, next_offset)
assert queryset == []
assert content.get('next') == next_url


class TestCursorPagination:
"""
Expand Down