diff options
| author | Claude Paroz <claude@2xlibre.net> | 2012-06-09 17:55:24 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2012-06-09 17:55:24 +0200 |
| commit | fc40a6504b78e604a6ba90a3b85b1ed54ee238a2 (patch) | |
| tree | 0cfbd2389dca6b2bd24910cdd315023dfc13586d /tests | |
| parent | ef906b163202679413f1fdae7106b8de86477dbe (diff) | |
Fixed #17159 -- Validated returned number of next|previous_page_number
Thanks mehta.apurva at gmail.com for the report and the initial patch
and neaf for the complete patch.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/modeltests/pagination/tests.py | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/tests/modeltests/pagination/tests.py b/tests/modeltests/pagination/tests.py index 9ced9edff2..4d5d8680e4 100644 --- a/tests/modeltests/pagination/tests.py +++ b/tests/modeltests/pagination/tests.py @@ -45,7 +45,7 @@ class PaginationTests(TestCase): self.assertFalse(p.has_previous()) self.assertTrue(p.has_other_pages()) self.assertEqual(2, p.next_page_number()) - self.assertEqual(0, p.previous_page_number()) + self.assertRaises(InvalidPage, p.previous_page_number) self.assertEqual(1, p.start_index()) self.assertEqual(5, p.end_index()) @@ -63,7 +63,7 @@ class PaginationTests(TestCase): self.assertFalse(p.has_next()) self.assertTrue(p.has_previous()) self.assertTrue(p.has_other_pages()) - self.assertEqual(3, p.next_page_number()) + self.assertRaises(InvalidPage, p.next_page_number) self.assertEqual(1, p.previous_page_number()) self.assertEqual(6, p.start_index()) self.assertEqual(9, p.end_index()) @@ -104,20 +104,20 @@ class PaginationTests(TestCase): def test_paginate_list(self): # Paginators work with regular lists/tuples, too -- not just with QuerySets. - paginator = Paginator([1, 2, 3, 4, 5, 6, 7, 8, 9], 5) + paginator = Paginator([1, 2, 3, 4, 5, 6, 7, 8, 9], 3) self.assertEqual(9, paginator.count) - self.assertEqual(2, paginator.num_pages) - self.assertEqual([1, 2], paginator.page_range) - p = paginator.page(1) - self.assertEqual("<Page 1 of 2>", unicode(p)) - self.assertEqual([1, 2, 3, 4, 5], p.object_list) + self.assertEqual(3, paginator.num_pages) + self.assertEqual([1, 2, 3], paginator.page_range) + p = paginator.page(2) + self.assertEqual("<Page 2 of 3>", unicode(p)) + self.assertEqual([4, 5, 6], p.object_list) self.assertTrue(p.has_next()) - self.assertFalse(p.has_previous()) + self.assertTrue(p.has_previous()) self.assertTrue(p.has_other_pages()) - self.assertEqual(2, p.next_page_number()) - self.assertEqual(0, p.previous_page_number()) - self.assertEqual(1, p.start_index()) - self.assertEqual(5, p.end_index()) + self.assertEqual(3, p.next_page_number()) + self.assertEqual(1, p.previous_page_number()) + self.assertEqual(4, p.start_index()) + self.assertEqual(6, p.end_index()) def test_paginate_misc_classes(self): # Paginator can be passed other objects with a count() method. |
