#NEWLINE# def test_paging( self ) : #NEWLINE# #INDENT# for coll_name in collections : #NEWLINE# #INDENT# coll = getattr ( self . service , coll_name ) #NEWLINE# expected = [ ent . name for ent in coll . list ( count = 30 ) ] #NEWLINE# if ( len ( expected ) == 0 ) : #NEWLINE# #INDENT# logging . debug ( 'No entities in collection %s; skipping test.' , coll_name ) #NEWLINE# #UNINDENT# total = len ( expected ) #NEWLINE# page_size = max ( int ( ( total / 5.0 ) ) , 1 ) #NEWLINE# found = [ ] #NEWLINE# offset = 0 #NEWLINE# while ( offset < total ) : #NEWLINE# #INDENT# page = coll . list ( offset = offset , count = page_size ) #NEWLINE# count = len ( page ) #NEWLINE# offset += count #NEWLINE# self . assertTrue ( ( ( count == page_size ) or ( offset == total ) ) , msg = ( 'on %s' % coll_name ) ) #NEWLINE# found . extend ( [ ent . name for ent in page ] ) #NEWLINE# logging . debug ( 'Iterate: offset=%d/%d' , offset , total ) #NEWLINE# #UNINDENT# self . assertEqual ( expected , found , msg = ( 'on %s (expected: %s, found: %s)' % ( coll_name , expected , found ) ) )