def test_pages(self): pager = UrlPaginator('/search', list(range(50)), 10) pages = pager.pages() self.assertEqual(4, len(pages)) pages = pager.page(2).pages() self.assertEqual(5, len(pages)) pages = pager.page(5).pages() self.assertEqual(4, len(pages)) self.assertEqual([1,2,3,4], [i['number'] for i in pager.pages()])
def test_pages(self): pager = UrlPaginator('/search', list(range(50)), 10) pages = pager.pages() self.assertEqual(4, len(pages)) pages = pager.page(2).pages() self.assertEqual(5, len(pages)) pages = pager.page(5).pages() self.assertEqual(4, len(pages)) self.assertEqual([1, 2, 3, 4], [i['number'] for i in pager.pages()])
def test_has_prev(self): pager = UrlPaginator('/search', object_list=list(range(10)), per_page=10) self.assertFalse(pager.has_prev()) pager = UrlPaginator('/search', object_list=list(range(11)), per_page=10) self.assertTrue(pager.page(2).has_prev())