Beispiel #1
0
 def setUp(self):
     self.p = FinitePaginator(range(20),
                              2,
                              offset=10,
                              link_template="/bacon/page/%d")
 def setUp(self):
     self.p = FinitePaginator(range(20), 2, offset=10, link_template='/bacon/page/%d')
Beispiel #3
0
class FinitePaginatorTestCase(SimpleTestCase):
    def setUp(self):
        self.p = FinitePaginator(range(20),
                                 2,
                                 offset=10,
                                 link_template="/bacon/page/%d")

    def test_repr(self):
        self.assertEqual(repr(FinitePaginator),
                         "<class 'dj_pagination.paginator.FinitePaginator'>")

    def test_validate_number(self):
        self.assertEqual(self.p.validate_number(2), 2)

    def test_orphans(self):
        self.assertEqual(self.p.orphans, 0)

    def test_page_repr(self):
        self.assertEqual(repr(self.p.page(3)), "<Page 3>")

    def test_page_start_index(self):
        self.assertEqual(self.p.page(3).start_index(), 10)

    def test_page_end(self):
        self.assertEqual(self.p.page(3).end_index(), 6)

    def test_page_has_next(self):
        self.assertTrue(self.p.page(3).has_next(), True)

    def test_page_has_previous(self):
        self.assertTrue(self.p.page(3).has_previous(), True)

    def test_page_next_link(self):
        self.assertEqual(self.p.page(3).next_link(), "/bacon/page/4")

    def test_page_previous_link(self):
        self.assertEqual(self.p.page(3).previous_link(), "/bacon/page/2")

    def test_on_start_page_repr(self):
        self.assertEqual(repr(self.p.page(2)), "<Page 2>")

    def test_on_start_has_no_next(self):
        self.assertTrue(self.p.page(2).has_next(), False)

    def test_on_start_has_previous(self):
        self.assertTrue(self.p.page(2).has_previous(), True)

    def test_on_start_has_next_link(self):
        self.assertEqual(self.p.page(2).next_link(), "/bacon/page/3")

    def test_on_start_has_previous_link(self):
        self.assertEqual(self.p.page(2).previous_link(), "/bacon/page/1")
class FinitePaginatorTestCase(SimpleTestCase):
    def setUp(self):
        self.p = FinitePaginator(range(20), 2, offset=10, link_template='/bacon/page/%d')

    def test_repr(self):
        self.assertEqual(
            repr(FinitePaginator),
            "<class 'dj_pagination.paginator.FinitePaginator'>"
        )

    def test_validate_number(self):
        self.assertEqual(self.p.validate_number(2), 2)

    def test_orphans(self):
        self.assertEqual(self.p.orphans, 0)

    def test_page_repr(self):
        self.assertEqual(repr(self.p.page(3)), '<Page 3>')

    def test_page_start_index(self):
        self.assertEqual(self.p.page(3).start_index(), 10)

    def test_page_end(self):
        self.assertEqual(self.p.page(3).end_index(), 6)

    def test_page_has_next(self):
        self.assertTrue(self.p.page(3).has_next(), True)

    def test_page_has_previous(self):
        self.assertTrue(self.p.page(3).has_previous(), True)

    def test_page_next_link(self):
        self.assertEqual(self.p.page(3).next_link(), '/bacon/page/4')

    def test_page_previous_link(self):
        self.assertEqual(self.p.page(3).previous_link(), '/bacon/page/2')

    def test_on_start_page_repr(self):
        self.assertEqual(repr(self.p.page(2)), '<Page 2>')

    def test_on_start_has_no_next(self):
        self.assertTrue(self.p.page(2).has_next(), False)

    def test_on_start_has_previous(self):
        self.assertTrue(self.p.page(2).has_previous(), True)

    def test_on_start_has_next_link(self):
        self.assertEqual(self.p.page(2).next_link(), '/bacon/page/3')

    def test_on_start_has_previous_link(self):
        self.assertEqual(self.p.page(2).previous_link(), '/bacon/page/1')