Esempio n. 1
0
    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()])
Esempio n. 2
0
    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()])
Esempio n. 3
0
    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())
Esempio n. 4
0
    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())