#NEWLINE# @ override_settings ( API_RESULT_PAGE_SIZE = 2 ) #NEWLINE# @ test . create_stubs ( { #NEWLINE# #INDENT# api . glance : ( 'image_list_detailed' , ) , #NEWLINE# api . keystone : ( 'tenant_list' , ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# def test_images_list_get_pagination( self ) : #NEWLINE# #INDENT# images = self . images . list ( ) [ : 5 ] #NEWLINE# filters = { #NEWLINE# #INDENT# 'is_public' : None , #NEWLINE# #UNINDENT# } #NEWLINE# kwargs = { #NEWLINE# #INDENT# 'paginate' : True , #NEWLINE# 'filters' : filters , #NEWLINE# 'sort_dir' : 'asc' , #NEWLINE# 'sort_key' : 'name' , #NEWLINE# 'reversed_order' : False , #NEWLINE# #UNINDENT# } #NEWLINE# api . glance . image_list_detailed ( IsA ( http . HttpRequest ) , marker = None , ** kwargs ) . AndReturn ( [ images , True , True ] ) #NEWLINE# api . glance . image_list_detailed ( IsA ( http . HttpRequest ) , marker = None , ** kwargs ) . AndReturn ( [ images [ : 2 ] , True , True ] ) #NEWLINE# api . glance . image_list_detailed ( IsA ( http . HttpRequest ) , marker = images [ 2 ] . id , ** kwargs ) . AndReturn ( [ images [ 2 : 4 ] , True , True ] ) #NEWLINE# api . glance . image_list_detailed ( IsA ( http . HttpRequest ) , marker = images [ 4 ] . id , ** kwargs ) . AndReturn ( [ images [ 4 : ] , True , True ] ) #NEWLINE# api . keystone . tenant_list ( IsA ( http . HttpRequest ) ) . MultipleTimes ( ) . AndReturn ( [ self . tenants . list ( ) , False ] ) #NEWLINE# self . mox . ReplayAll ( ) #NEWLINE# url = reverse ( 'horizon:admin:images:index' ) #NEWLINE# res = self . client . get ( url ) #NEWLINE# self . assertEqual ( len ( res . context [ 'images_table' ] . data ) , len ( images ) ) #NEWLINE# self . assertTemplateUsed ( res , 'admin/images/index.html' ) #NEWLINE# self . assertContains ( res , 'test_tenant' , 6 , 200 ) #NEWLINE# res = self . client . get ( url ) #NEWLINE# self . assertEqual ( len ( res . context [ 'images_table' ] . data ) , settings . API_RESULT_PAGE_SIZE ) #NEWLINE# params = '=' . join ( [ tables . AdminImagesTable . _meta . pagination_param , images [ 2 ] . id ] ) #NEWLINE# url = '?' . join ( [ reverse ( 'horizon:admin:images:index' ) , params ] ) #NEWLINE# res = self . client . get ( url ) #NEWLINE# self . assertEqual ( len ( res . context [ 'images_table' ] . data ) , settings . API_RESULT_PAGE_SIZE ) #NEWLINE# self . assertContains ( res , 'test_tenant' , 3 , 200 ) #NEWLINE# params = '=' . join ( [ tables . AdminImagesTable . _meta . pagination_param , images [ 4 ] . id ] ) #NEWLINE# url = '?' . join ( [ reverse ( 'horizon:admin:images:index' ) , params ] ) #NEWLINE# res = self . client . get ( url ) #NEWLINE# self . assertEqual ( len ( res . context [ 'images_table' ] . data ) , 1 ) #NEWLINE# self . assertContains ( res , 'test_tenant' , 2 , 200 )