#NEWLINE# @ mock . patch ( 'nova.image.glance._translate_from_glance' ) #NEWLINE# @ mock . patch ( 'nova.image.glance._translate_to_glance' ) #NEWLINE# def test_update_success( self , trans_to_mock , trans_from_mock ) : #NEWLINE# #INDENT# translated = { #NEWLINE# #INDENT# 'id' : mock . sentinel . image_id , #NEWLINE# 'name' : mock . sentinel . name , #NEWLINE# #UNINDENT# } #NEWLINE# trans_to_mock . return_value = translated #NEWLINE# trans_from_mock . return_value = mock . sentinel . trans_from #NEWLINE# image_mock = mock . MagicMock ( spec = dict ) #NEWLINE# client = mock . MagicMock ( ) #NEWLINE# client . call . return_value = mock . sentinel . image_meta #NEWLINE# ctx = mock . sentinel . ctx #NEWLINE# service = glance . GlanceImageService ( client ) #NEWLINE# image_meta = service . update ( ctx , mock . sentinel . image_id , self ) #NEWLINE# trans_to_mock . assert_called_once_with ( image_mock ) #NEWLINE# client . call . assert_called_once_with ( ctx , 1 , 'update' , mock . sentinel . image_id , name = mock . sentinel . name , purge_props = True ) #NEWLINE# trans_from_mock . assert_called_once_with ( mock . sentinel . image_meta ) #NEWLINE# self . assertEqual ( mock . sentinel . trans_from , image_meta ) #NEWLINE# client . reset_mock ( ) #NEWLINE# service . update ( ctx , mock . sentinel . image_id , image_mock , data = mock . sentinel . data ) #NEWLINE# client . call . assert_called_once_with ( ctx , 1 , 'update' , mock . sentinel . image_id , name = mock . sentinel . name , purge_props = True , data = mock . sentinel . data )