Implement pagination

This commit is contained in:
Vincent Jacques
2012-02-18 05:07:03 +00:00
parent c8b807b6ff
commit 193a9829ab
2 changed files with 25 additions and 7 deletions
+6
View File
@@ -49,4 +49,10 @@ class TestCase( unittest.TestCase ):
self.expect( "GET", "/test?tata=tutu&toto=titi", '{"xxx": 42}', 200, [], '{ "foo": "bar" }' )
self.assertEqual( self.r.dataRequest( "GET", "/test", { "toto" : "titi", "tata" : "tutu" }, { "xxx" : 42 } ), { "foo" : "bar" } )
def testPagination( self ):
self.expect( "GET", "/test", 'null', 200, [ ( "link", "xxx; next, xxx; last" ) ], '[ 1, 2 ]' )
self.expect( "GET", "/test?page=2", 'null', 200, [ ( "link", "xxx; prev, xxx; first, xxx; next, xxx; last" ) ], '[ 3, 4 ]' )
self.expect( "GET", "/test?page=3", 'null', 200, [ ( "link", "xxx; prev, xxx; first" ) ], '[ 5, 6 ]' )
self.assertEqual( self.r.dataRequest( "GET", "/test", None, None ), [ 1, 2, 3, 4, 5, 6 ] )
unittest.main()