          request = Request(factory.get(previous_url))
          queryset = self.paginate_queryset(request)
          assert [item.created for item in queryset] == [1, 2, 3, 4, 5]
  
          previous_url = self.pagination.get_previous_link()
          assert previous_url is None
  
  
  class TestCrazyCursorPagination:
      """
      Unit tests for `pagination.CursorPagination`.
      """
  
      def setup(self):
          class MockObject(object):
              def __init__(self, idx):
                  self.created = idx
  
          class MockQuerySet(object):
              def __init__(self, items):
                  self.items = items
  
              def filter(self, created__gt=None, created__lt=None):
                  if created__gt is not None:
                      return MockQuerySet([
                          item for item in self.items
 
</s> remove             def filter(self, created__gt=None, created__lt=None):
                if created__gt is not None:
                    return MockQuerySet([
                        item for item in self.items
                        if item.created > int(created__gt)
                    ])
 </s> add     def test_cursor_pagination(self):
        (previous, current, next, previous_url, next_url) = self.get_pages('/') </s> remove         previous_url = self.pagination.get_previous_link()
        assert previous_url
 </s> add         if previous_url is not None:
            request = Request(factory.get(previous_url))
            queryset = self.pagination.paginate_queryset(self.queryset, request)
            previous = [item.created for item in queryset]
        else:
            previous = None </s> remove         self.pagination = pagination.CursorPagination()
        self.queryset = MockQuerySet(
            [MockObject(idx) for idx in range(1, 16)]
        )

    def paginate_queryset(self, request):
        return list(self.pagination.paginate_queryset(self.queryset, request))

    # def get_paginated_content(self, queryset):
    #     response = self.pagination.get_paginated_response(queryset)
    #     return response.data

    # def get_html_context(self):
    #     return self.pagination.get_html_context()

    def test_following_cursor(self):
        request = Request(factory.get('/'))
        queryset = self.paginate_queryset(request)
        assert [item.created for item in queryset] == [1, 2, 3, 4, 5]

        next_url = self.pagination.get_next_link()
        assert next_url
 </s> add         class ExamplePagination(pagination.CursorPagination):
            page_size = 5 </s> remove         request = Request(factory.get(previous_url))
        queryset = self.paginate_queryset(request)
        assert [item.created for item in queryset] == [6, 7, 8, 9, 10]
 </s> add         if next_url is not None:
            request = Request(factory.get(next_url))
            queryset = self.pagination.paginate_queryset(self.queryset, request)
            next = [item.created for item in queryset]
        else:
            next = None </s> remove         request = Request(factory.get(previous_url))
        queryset = self.paginate_queryset(request)
        assert [item.created for item in queryset] == [1, 2, 3, 4, 5]
 </s> add         return (previous, current, next, previous_url, next_url)
    def test_invalid_cursor(self):
        request = Request(factory.get('/', {'cursor': '123'}))
        with pytest.raises(exceptions.NotFound):
            self.pagination.paginate_queryset(self.queryset, request)
          request = Request(factory.get(previous_url))
          queryset = self.paginate_queryset(request)
          assert [item.created for item in queryset] == [1, 2, 3, 4, 5]
  
    def test_invalid_cursor(self):
        request = Request(factory.get('/', {'cursor': '123'}))
        with pytest.raises(exceptions.NotFound):
            self.pagination.paginate_queryset(self.queryset, request)
    def test_invalid_cursor(self):
        request = Request(factory.get('/', {'cursor': '123'}))
        with pytest.raises(exceptions.NotFound):
            self.pagination.paginate_queryset(self.queryset, request)
    def test_invalid_cursor(self):
        request = Request(factory.get('/', {'cursor': '123'}))
        with pytest.raises(exceptions.NotFound):
            self.pagination.paginate_queryset(self.queryset, request)
    def test_invalid_cursor(self):
        request = Request(factory.get('/', {'cursor': '123'}))
        with pytest.raises(exceptions.NotFound):
            self.pagination.paginate_queryset(self.queryset, request)
    def test_invalid_cursor(self):
        request = Request(factory.get('/', {'cursor': '123'}))
        with pytest.raises(exceptions.NotFound):
            self.pagination.paginate_queryset(self.queryset, request)
    def test_invalid_cursor(self):
        request = Request(factory.get('/', {'cursor': '123'}))
        with pytest.raises(exceptions.NotFound):
            self.pagination.paginate_queryset(self.queryset, request)
    def test_invalid_cursor(self):
        request = Request(factory.get('/', {'cursor': '123'}))
        with pytest.raises(exceptions.NotFound):
            self.pagination.paginate_queryset(self.queryset, request)
    def test_invalid_cursor(self):
        request = Request(factory.get('/', {'cursor': '123'}))
        with pytest.raises(exceptions.NotFound):
            self.pagination.paginate_queryset(self.queryset, request)
    def test_invalid_cursor(self):
        request = Request(factory.get('/', {'cursor': '123'}))
        with pytest.raises(exceptions.NotFound):
            self.pagination.paginate_queryset(self.queryset, request)
    def test_invalid_cursor(self):
        request = Request(factory.get('/', {'cursor': '123'}))
        with pytest.raises(exceptions.NotFound):
            self.pagination.paginate_queryset(self.queryset, request)
    def test_invalid_cursor(self):
        request = Request(factory.get('/', {'cursor': '123'}))
        with pytest.raises(exceptions.NotFound):
            self.pagination.paginate_queryset(self.queryset, request)
    def test_invalid_cursor(self):
        request = Request(factory.get('/', {'cursor': '123'}))
        with pytest.raises(exceptions.NotFound):
            self.pagination.paginate_queryset(self.queryset, request)
    def test_invalid_cursor(self):
        request = Request(factory.get('/', {'cursor': '123'}))
        with pytest.raises(exceptions.NotFound):
            self.pagination.paginate_queryset(self.queryset, request)
    def test_invalid_cursor(self):
        request = Request(factory.get('/', {'cursor': '123'}))
        with pytest.raises(exceptions.NotFound):
            self.pagination.paginate_queryset(self.queryset, request)
    def test_invalid_cursor(self):
        request = Request(factory.get('/', {'cursor': '123'}))
        with pytest.raises(exceptions.NotFound):
            self.pagination.paginate_queryset(self.queryset, request)
    def test_invalid_cursor(self):
        request = Request(factory.get('/', {'cursor': '123'}))
        with pytest.raises(exceptions.NotFound):
            self.pagination.paginate_queryset(self.queryset, request)
    def test_invalid_cursor(self):
        request = Request(factory.get('/', {'cursor': '123'}))
        with pytest.raises(exceptions.NotFound):
            self.pagination.paginate_queryset(self.queryset, request)
  
              def filter(self, created__gt=None, created__lt=None):
                  if created__gt is not None:
                      return MockQuerySet([
                          item for item in self.items
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Tidy up cursor tests and make more comprehensive 
tests/test_pagination.py