From 0429201ddb9276b5e47a1eb48196f4f9c33eac55 Mon Sep 17 00:00:00 2001 From: Nick Horelik Date: Thu, 24 Sep 2015 22:49:57 +0000 Subject: [PATCH] Added test for limit=0 when using LimitOffsetPagination --- tests/test_pagination.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_pagination.py b/tests/test_pagination.py index 63fdbecae..c0f341cd2 100644 --- a/tests/test_pagination.py +++ b/tests/test_pagination.py @@ -481,6 +481,21 @@ class TestLimitOffset: 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: """