#NEWLINE# @ mock . patch . object ( seamicro , '_get_server' , autospec = True ) #NEWLINE# @ mock . patch . object ( seamicro , '_validate_volume' , autospec = True ) #NEWLINE# def test_attach_volume_fail( self , mock_validate_volume , mock_get_server ) : #NEWLINE# #INDENT# def fake_attach_volume( self , **kwargs ) : #NEWLINE# #INDENT# raise seamicro_client_exception . ClientException ( http_client . INTERNAL_SERVER_ERROR ) #NEWLINE# #UNINDENT# volume_id = '0/p6-1/vol1' #NEWLINE# mock_validate_volume . return_value = True #NEWLINE# server = self . Server ( active = 'true' ) #NEWLINE# server . attach_volume = fake_attach_volume #NEWLINE# mock_get_server . return_value = server #NEWLINE# with task_manager . acquire ( self . context , self . info [ 'uuid' ] , shared = False ) as task : #NEWLINE# #INDENT# kwargs = { #NEWLINE# #INDENT# 'volume_id' : volume_id , #NEWLINE# #UNINDENT# } #NEWLINE# self . assertRaises ( exception . IronicException , task . driver . vendor . attach_volume , task , ** kwargs ) #NEWLINE# #UNINDENT# mock_get_server . assert_called_once_with ( self . info )