#NEWLINE# @ skip_if_disabled #NEWLINE# def test_limited_images( self ) : #NEWLINE# #INDENT# '\n        Ensure marker and limit query params work\n        ' #NEWLINE# self . cleanup ( ) #NEWLINE# self . start_servers ( ** self . __dict__ . copy ( ) ) #NEWLINE# path = ( 'https://%s:%d/v1/images' % ( '0.0.0.0' , self . api_port ) ) #NEWLINE# https = httplib2 . Http ( disable_ssl_certificate_validation = True ) #NEWLINE# ( response , content ) = https . request ( path , 'GET' ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# self . assertEqual ( content , '{"images": []}' ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'Content-Type' : 'application/octet-stream' , #NEWLINE# 'X-Image-Meta-Name' : 'Image1' , #NEWLINE# 'X-Image-Meta-Is-Public' : 'True' , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'https://%s:%d/v1/images' % ( '0.0.0.0' , self . api_port ) ) #NEWLINE# https = httplib2 . Http ( disable_ssl_certificate_validation = True ) #NEWLINE# ( response , content ) = https . request ( path , 'POST' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 201 ) #NEWLINE# data = json . loads ( content ) #NEWLINE# image_ids = [ data [ 'image' ] [ 'id' ] ] #NEWLINE# headers = { #NEWLINE# #INDENT# 'Content-Type' : 'application/octet-stream' , #NEWLINE# 'X-Image-Meta-Name' : 'Image2' , #NEWLINE# 'X-Image-Meta-Is-Public' : 'True' , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'https://%s:%d/v1/images' % ( '0.0.0.0' , self . api_port ) ) #NEWLINE# https = httplib2 . Http ( disable_ssl_certificate_validation = True ) #NEWLINE# ( response , content ) = https . request ( path , 'POST' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 201 ) #NEWLINE# data = json . loads ( content ) #NEWLINE# image_ids . append ( data [ 'image' ] [ 'id' ] ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'Content-Type' : 'application/octet-stream' , #NEWLINE# 'X-Image-Meta-Name' : 'Image3' , #NEWLINE# 'X-Image-Meta-Is-Public' : 'True' , #NEWLINE# #UNINDENT# } #NEWLINE# path = ( 'https://%s:%d/v1/images' % ( '0.0.0.0' , self . api_port ) ) #NEWLINE# https = httplib2 . Http ( disable_ssl_certificate_validation = True ) #NEWLINE# ( response , content ) = https . request ( response , 'POST' , headers = headers ) #NEWLINE# self . assertEqual ( response . status , 201 ) #NEWLINE# data = json . loads ( content ) #NEWLINE# image_ids . append ( data [ 'image' ] [ 'id' ] ) #NEWLINE# params = 'limit=2' #NEWLINE# path = ( 'https://%s:%d/v1/images?%s' % ( '0.0.0.0' , self . api_port , params ) ) #NEWLINE# ( response , content ) = https . request ( path , 'GET' ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# data = json . loads ( content ) #NEWLINE# self . assertEqual ( len ( data [ 'images' ] ) , 2 ) #NEWLINE# self . assertEqual ( data [ 'images' ] [ 0 ] [ 'id' ] , image_ids [ 2 ] ) #NEWLINE# self . assertEqual ( data [ 'images' ] [ 1 ] [ 'id' ] , image_ids [ 1 ] ) #NEWLINE# params = ( 'marker=%s' % image_ids [ 2 ] ) #NEWLINE# path = ( 'https://%s:%d/v1/images?%s' % ( '0.0.0.0' , self . api_port , params ) ) #NEWLINE# ( response , content ) = https . request ( path , 'GET' ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# data = json . loads ( content ) #NEWLINE# self . assertEqual ( len ( data [ 'images' ] ) , 2 ) #NEWLINE# self . assertEqual ( data [ 'images' ] [ 0 ] [ 'id' ] , image_ids [ 1 ] ) #NEWLINE# self . assertEqual ( data [ 'images' ] [ 1 ] [ 'id' ] , image_ids [ 0 ] ) #NEWLINE# params = ( 'limit=1&marker=%s' % image_ids [ 1 ] ) #NEWLINE# path = ( 'https://%s:%d/v1/images?%s' % ( '0.0.0.0' , self . api_port , params ) ) #NEWLINE# ( response , content ) = https . request ( path , 'GET' ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# data = json . loads ( content ) #NEWLINE# self . assertEqual ( len ( data [ 'images' ] ) , 1 ) #NEWLINE# self . assertEqual ( data [ 'images' ] [ 0 ] [ 'id' ] , image_ids [ 0 ] ) #NEWLINE# params = ( 'limit=1&marker=%s' % image_ids [ 2 ] ) #NEWLINE# path = ( 'https://%s:%d/v1/images?%s' % ( '0.0.0.0' , self . api_port , params ) ) #NEWLINE# ( response , content ) = https . request ( path , 'GET' ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# data = json . loads ( content ) #NEWLINE# self . assertEqual ( len ( data [ 'images' ] ) , 1 ) #NEWLINE# self . assertEqual ( data [ 'images' ] [ 0 ] [ 'id' ] , image_ids [ 1 ] ) #NEWLINE# self . stop_servers ( )