#NEWLINE# @ mock . patch ( 'nova.image.glance._translate_from_glance' ) #NEWLINE# @ mock . patch ( 'nova.image.glance._is_image_available' ) #NEWLINE# def test_include_direct_uri_success( self , avail_mock , trans_from_mock ) : #NEWLINE# #INDENT# locations = [ mock . sentinel . loc1 ] #NEWLINE# avail_mock . return_value = True #NEWLINE# trans_from_mock . return_value = { #NEWLINE# #INDENT# 'locations' : locations , #NEWLINE# 'direct_uri' : mock . sentinel . duri , #NEWLINE# #UNINDENT# } #NEWLINE# client = mock . Mock ( ) #NEWLINE# client . call . return_value = mock . sentinel . image #NEWLINE# service = glance . GlanceImageService ( client ) #NEWLINE# ctx = mock . sentinel . ctx #NEWLINE# image_id = mock . sentinel . image_id #NEWLINE# info = service . show ( ctx , image_id , include_locations = True ) #NEWLINE# client . call . assert_called_once_with ( info , 2 , 'get' , image_id ) #NEWLINE# expected = locations #NEWLINE# expected . append ( { #NEWLINE# #INDENT# 'url' : mock . sentinel . duri , #NEWLINE# 'metadata' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertIn ( 'locations' , info ) #NEWLINE# self . assertEqual ( expected , info [ 'locations' ] )