Example #1
0
class InfinitePaginatorTestCase(SimpleTestCase):
    def setUp(self):
        self.p = InfinitePaginator(range(20),
                                   2,
                                   link_template="/bacon/page/%d")

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

    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_end_index(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_last_page_which_has_no_next_page(self):
        self.assertFalse(self.p.page(10).has_next())

    def test_first_page_which_has_no_previous_page(self):
        self.assertFalse(self.p.page(1).has_previous())
Example #2
0
class InfinitePaginatorTestCase(SimpleTestCase):
    def setUp(self):
        self.p = InfinitePaginator(range(20), 2, link_template='/bacon/page/%d')

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

    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_end_index(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_last_page_which_has_no_next_page(self):
        self.assertFalse(self.p.page(10).has_next())

    def test_first_page_which_has_no_previous_page(self):
        self.assertFalse(self.p.page(1).has_previous())
Example #3
0
 def setUp(self):
     self.p = InfinitePaginator(range(20),
                                2,
                                link_template="/bacon/page/%d")
Example #4
0
 def setUp(self):
     self.p = InfinitePaginator(range(20), 2, link_template='/bacon/page/%d')