#NEWLINE# def test_node_power_action_failed_getting_state( self ) : #NEWLINE# #INDENT# "Test for exception when we can't get the current power state." #NEWLINE# node = obj_utils . create_test_node ( self . context , uuid = uuidutils . generate_uuid ( ) , driver = 'fake' , power_state = states . POWER_ON ) #NEWLINE# task = task_manager . TaskManager ( self . context , node . uuid ) #NEWLINE# with mock . patch . object ( self . driver . power , 'get_power_state' ) as get_power_state_mock : #NEWLINE# #INDENT# get_power_state_mock . side_effect = exception . InvalidParameterValue ( 'failed getting power state' ) #NEWLINE# self . assertRaises ( exception . InvalidParameterValue , conductor_utils . node_power_action , task , states . POWER_ON ) #NEWLINE# node . refresh ( ) #NEWLINE# get_power_state_mock . assert_called_once_with ( mock . ANY ) #NEWLINE# self . assertEqual ( states . POWER_ON , node [ 'power_state' ] ) #NEWLINE# self . assertIsNone ( node [ 'target_power_state' ] ) #NEWLINE# self . assertIsNotNone ( node [ 'last_error' ] )