#NEWLINE# @ mock . patch ( 'ironic_python_agent.hardware.dispatch_to_managers' , autospec = True ) #NEWLINE# @ mock . patch ( 'ironic_python_agent.extensions.standby._write_image' , autospec = True ) #NEWLINE# @ mock . patch ( 'ironic_python_agent.extensions.standby._download_image' , autospec = True ) #NEWLINE# def test_cache_image( self , download_mock , write_mock , dispatch_mock ) : #NEWLINE# #INDENT# image_info = _build_fake_image_info ( ) #NEWLINE# download_mock . return_value = None #NEWLINE# write_mock . return_value = None #NEWLINE# dispatch_mock . return_value = 'manager' #NEWLINE# async_result = self . agent_extension . cache_image ( image_info = image_info ) #NEWLINE# async_result . join ( ) #NEWLINE# download_mock . assert_called_once_with ( image_info ) #NEWLINE# write_mock . assert_called_once_with ( image_info , 'manager' ) #NEWLINE# dispatch_mock . assert_called_once_with ( 'get_os_install_device' ) #NEWLINE# self . assertEqual ( image_info [ 'id' ] , self . agent_extension . cached_image_id ) #NEWLINE# self . assertEqual ( 'SUCCEEDED' , async_result . command_status ) #NEWLINE# self . assertTrue ( ( 'result' in async_result . command_result . keys ( ) ) ) #NEWLINE# cmd_result = 'cache_image: image ({0}) cached to device {1} ' . format ( image_info [ 'id' ] , 'manager' ) #NEWLINE# self . assertEqual ( async_result , async_result . command_result [ 'result' ] )