summaryrefslogtreecommitdiff
path: root/tests/pagination/custom.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/pagination/custom.py')
-rw-r--r--tests/pagination/custom.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/pagination/custom.py b/tests/pagination/custom.py
index ea04083576..e1ffa905f1 100644
--- a/tests/pagination/custom.py
+++ b/tests/pagination/custom.py
@@ -1,4 +1,4 @@
-from django.core.paginator import Page, Paginator
+from django.core.paginator import AsyncPage, AsyncPaginator, Page, Paginator
class ValidAdjacentNumsPage(Page):
@@ -16,3 +16,20 @@ class ValidAdjacentNumsPage(Page):
class ValidAdjacentNumsPaginator(Paginator):
def _get_page(self, *args, **kwargs):
return ValidAdjacentNumsPage(*args, **kwargs)
+
+
+class AsyncValidAdjacentNumsPage(AsyncPage):
+ async def anext_page_number(self):
+ if not await self.ahas_next():
+ return None
+ return await super().anext_page_number()
+
+ async def aprevious_page_number(self):
+ if not await self.ahas_previous():
+ return None
+ return await super().aprevious_page_number()
+
+
+class AsyncValidAdjacentNumsPaginator(AsyncPaginator):
+ def _get_page(self, *args, **kwargs):
+ return AsyncValidAdjacentNumsPage(*args, **kwargs)