mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-23 22:49:50 +03:00
Fix pagination tests
This commit is contained in:
parent
df5d07ac53
commit
e44d8de067
|
@ -621,7 +621,7 @@ class CursorPagination(BasePagination):
|
|||
queryset = queryset.order_by(*self.ordering)
|
||||
|
||||
# If we have a cursor with a fixed position then filter by that.
|
||||
if current_position is not None:
|
||||
if str(current_position) != 'None':
|
||||
order = self.ordering[0]
|
||||
is_reversed = order.startswith('-')
|
||||
order_attr = order.lstrip('-')
|
||||
|
|
|
@ -951,17 +951,21 @@ class TestCursorPagination(CursorPaginationTestsMixin):
|
|||
def __init__(self, items):
|
||||
self.items = items
|
||||
|
||||
def filter(self, created__gt=None, created__lt=None):
|
||||
def filter(self, q):
|
||||
q_args = dict(q.deconstruct()[1])
|
||||
created__gt = q_args.get('created__gt')
|
||||
created__lt = q_args.get('created__lt')
|
||||
|
||||
if created__gt is not None:
|
||||
return MockQuerySet([
|
||||
item for item in self.items
|
||||
if item.created > int(created__gt)
|
||||
if item.created is None or item.created > int(created__gt)
|
||||
])
|
||||
|
||||
assert created__lt is not None
|
||||
return MockQuerySet([
|
||||
item for item in self.items
|
||||
if item.created < int(created__lt)
|
||||
if item.created is None or item.created < int(created__lt)
|
||||
])
|
||||
|
||||
def order_by(self, *ordering):
|
||||
|
|
Loading…
Reference in New Issue
Block a user