Пример #1
0
    async def test_pagination_items_per_page(self):
        items_per_page = 2
        paginator = BaseCursorPagination(Model.id, items_per_page, model=Model)
        paginator.model = Model
        queryset = Model.select().order_by(Model.id)
        queryset = paginator.first(queryset, None, None)
        result = queryset.execute()

        self.assertEqual(len(result), items_per_page)
Пример #2
0
    async def test_pagination_first_page(self):
        queryset = Model.select().order_by(Model.id)
        queryset = self.paginator.first(queryset, None, None)
        result = queryset.execute()
        ids = [i.id for i in result]

        self.assertEqual(len(result), settings.PAGINATE_BY)
        self.assertIn(1, ids)
        self.assertIn(settings.PAGINATE_BY, ids)