#NEWLINE# def test_api_response_when_image_deleted_from_filesystem( self ) : #NEWLINE# #INDENT# '\n        A test for LP bug #781410 -- glance should fail more gracefully\n        on requests for images that have been removed from the fs\n        ' #NEWLINE# self . cleanup ( ) #NEWLINE# self . start_servers ( ) #NEWLINE# image_data = ( '*' * FIVE_KB ) #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 = ( 'http://%s:%d/v1/images' % ( '0.0.0.0' , self . api_port ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'POST' , headers = headers , body = image_data ) #NEWLINE# self . assertEqual ( response . status , 201 ) #NEWLINE# data = json . loads ( content ) #NEWLINE# self . assertEqual ( data [ 'image' ] [ 'checksum' ] , hashlib . md5 ( image_data ) . hexdigest ( ) ) #NEWLINE# self . assertEqual ( data [ 'image' ] [ 'size' ] , FIVE_KB ) #NEWLINE# self . assertEqual ( content [ 'image' ] [ 'name' ] , 'Image1' ) #NEWLINE# self . assertEqual ( data [ 'image' ] [ 'is_public' ] , True ) #NEWLINE# image_path = ( '%s/images/%s' % ( self . test_dir , data [ 'image' ] [ 'id' ] ) ) #NEWLINE# os . remove ( image_path ) #NEWLINE# path = ( 'http://%s:%d/v1/images/%s' % ( '0.0.0.0' , self . api_port , data [ 'image' ] [ 'id' ] ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'HEAD' ) #NEWLINE# self . assertEqual ( response . status , 200 ) #NEWLINE# self . assertEqual ( response [ 'x-image-meta-name' ] , 'Image1' ) #NEWLINE# path = ( 'http://%s:%d/v1/images/1' % ( '0.0.0.0' , self . api_port ) ) #NEWLINE# http = httplib2 . Http ( ) #NEWLINE# ( response , content ) = http . request ( path , 'GET' ) #NEWLINE# self . assertEqual ( response . status , 404 ) #NEWLINE# self . stop_servers ( )