#NEWLINE# @ mock . patch ( 'six.moves.builtins.open' , autospec = True ) #NEWLINE# @ mock . patch ( 'ironic_python_agent.utils.execute' , autospec = True ) #NEWLINE# def test_write_image( self , execute_mock , open_mock ) : #NEWLINE# #INDENT# image_info = _build_fake_image_info ( ) #NEWLINE# device = '/dev/sda' #NEWLINE# location = standby . _image_location ( image_info ) #NEWLINE# script = standby . _path_to_script ( 'shell/write_image.sh' ) #NEWLINE# command = [ '/bin/bash' , script , location , device ] #NEWLINE# execute_mock . return_value = ( '' , '' ) #NEWLINE# standby . _write_image ( image_info , device ) #NEWLINE# execute_mock . assert_called_once_with ( * command , check_exit_code = [ 0 ] ) #NEWLINE# execute_mock . reset_mock ( ) #NEWLINE# execute_mock . return_value = ( '' , '' ) #NEWLINE# execute_mock . side_effect = processutils . ProcessExecutionError #NEWLINE# self . assertRaises ( errors . ImageWriteError , standby . _write_image , image_info , device ) #NEWLINE# execute_mock . assert_called_once_with ( * command , check_exit_code = [ 0 ] )