<s> from __future__ import absolute_import <EOL> import pytest <EOL> from sentry . api . paginator import ( <EOL> DateTimePaginator , OffsetPaginator <EOL> ) <EOL> from sentry . models import User <EOL> from sentry . testutils import TestCase <EOL> class OffsetPaginatorTest ( TestCase ) : <EOL> def test_simple ( self ) : <EOL> res1 = self . create_user ( '<STR_LIT>' ) <EOL> res2 = self . create_user ( '<STR_LIT>' ) <EOL> res3 = self . create_user ( '<STR_LIT>' ) <EOL> queryset = User . objects . all ( ) <EOL> paginator = OffsetPaginator ( queryset , '<STR_LIT:id>' ) <EOL> result1 = paginator . get_result ( limit = <NUM_LIT:1> , cursor = None ) <EOL> assert len ( result1 ) == <NUM_LIT:1> , result1 <EOL> assert result1 [ <NUM_LIT:0> ] == res1 <EOL> assert result1 . next <EOL> assert not result1 . prev <EOL> result2 = paginator . get_result ( limit = <NUM_LIT:1> , cursor = result1 . next ) <EOL> assert len ( result2 ) == <NUM_LIT:1> , ( result2 , list ( result2 ) ) <EOL> assert result2 [ <NUM_LIT:0> ] == res2 <EOL> assert result2 . next <EOL> assert result2 . prev <EOL> result3 = paginator . get_result ( limit = <NUM_LIT:1> , cursor = result2 . next ) <EOL> assert len ( result3 ) == <NUM_LIT:1> , result3 <EOL> assert result3 [ <NUM_LIT:0> ] == res3 <EOL> assert not result3 . next <EOL> assert result3 . prev <EOL> result4 = paginator . get_result ( limit = <NUM_LIT:1> , cursor = result3 . next ) <EOL> assert len ( result4 ) == <NUM_LIT:0> , result4 <EOL> assert not result4 . next <EOL> assert result4 . prev <EOL> result5 = paginator . get_result ( limit = <NUM_LIT:1> , cursor = result4 . prev ) <EOL> assert len ( result5 ) == <NUM_LIT:1> , result5 <EOL> assert result5 [ <NUM_LIT:0> ] == res3 <EOL> assert not result5 . next <EOL> assert result5 . prev <EOL> class DateTimePaginatorTest ( TestCase ) : <EOL> @ pytest . mark . xfail <EOL> def test_simple ( self ) : <EOL> res1 = self . create_user ( '<STR_LIT>' ) <EOL> res2 = self . create_user ( '<STR_LIT>' ) <EOL> res3 = self . create_user ( '<STR_LIT>' ) <EOL> queryset = User . objects . all ( ) <EOL> paginator = DateTimePaginator ( queryset , '<STR_LIT>' ) <EOL> result1 = paginator . get_result ( limit = <NUM_LIT:1> , cursor = None ) <EOL> assert len ( result1 ) == <NUM_LIT:1> , result1 <EOL> assert result1 [ <NUM_LIT:0> ] == res1 <EOL> assert result1 . next <EOL> assert not result1 . prev <EOL> result2 = paginator . get_result ( limit = <NUM_LIT:2> , cursor = result1 . next ) <EOL> assert len ( result2 ) == <NUM_LIT:2> , result2 <EOL> assert result2 [ <NUM_LIT:0> ] == res2 <EOL> assert result2 [ <NUM_LIT:1> ] == res3 <EOL> assert not result2 . next <EOL> assert result2 . prev <EOL> result3 = paginator . get_result ( limit = <NUM_LIT:2> , cursor = result2 . prev ) <EOL> assert len ( result3 ) == <NUM_LIT:1> , list ( result3 ) <EOL> assert result3 [ <NUM_LIT:0> ] == res1 <EOL> assert result3 . next <EOL> assert not result3 . prev </s>
