Esempio n. 1
0
    def test__next_last_cursor__odd(self):
        element_list = [num for num in range(0, 5)]
        pagination_list = Pagination(element_list, 2)

        next_cursor = pagination_list.next_cursor
        next_cursor = pagination_list.next_cursor
        self.assertEqual(len(pagination_list.page(next_cursor)[0]), 1)

        last_cursor = pagination_list.next_cursor
        self.assertFalse(last_cursor)
Esempio n. 2
0
    def test__encode_cursor(self):
        element_list = [num for num in range(0, 5)]
        pagination_list = Pagination(element_list, 2)

        cursor = pagination_list.cursor

        self.assertEqual(cursor, 'MA==')
Esempio n. 3
0
    def test__create_pagination_object_max_size(self):
        element_list = [num for num in range(0, 10)]

        pagination_list = Pagination(element_list, 150)

        self.assertEqual(pagination_list.page_size,
                         pagination_list.MAX_PAGE_SIZE)
Esempio n. 4
0
    def test__next_cursor_last_page(self):
        element_list = [num for num in range(0, 4)]
        pagination_list = Pagination(element_list, 2)

        next_cursor = pagination_list.next_cursor
        last_cursor = pagination_list.next_cursor
        self.assertFalse(last_cursor)
Esempio n. 5
0
    def test__next_cursor(self):
        element_list = [num for num in range(0, 10)]
        pagination_list = Pagination(element_list, 2)

        next_cursor = pagination_list.next_cursor
        self.assertEqual(next_cursor, 'Mg==')
Esempio n. 6
0
    def test__page__out_of_range_cursor(self):
        element_list = [num for num in range(0, 10)]
        pagination_list = Pagination(element_list, 2)

        page = pagination_list.page('MTA=')
        self.assertListEqual(page[0], element_list[8:10])
Esempio n. 7
0
    def test__page__negative_cursor(self):
        element_list = [num for num in range(0, 10)]
        pagination_list = Pagination(element_list, 2)

        page = pagination_list.page('LTE=')
        self.assertListEqual(page[0], element_list[:2])
Esempio n. 8
0
    def test__page(self):
        element_list = [num for num in range(0, 10)]
        pagination_list = Pagination(element_list, 2)

        page = pagination_list.page('MA==')
        self.assertListEqual(page[0], element_list[:2])
Esempio n. 9
0
    def test__create_pagination_object(self):
        element_list = [num for num in range(0, 10)]
        pagination_list = Pagination(element_list, 2)

        self.assertIsInstance(pagination_list, Pagination)