#NEWLINE# @ mock . patch . object ( driver_utils , 'get_node_mac_addresses' , autospec = True ) #NEWLINE# @ mock . patch . object ( ssh , '_get_connection' , autospec = True ) #NEWLINE# @ mock . patch . object ( ssh , '_power_off' , autospec = True ) #NEWLINE# def test_set_power_state_off_good( self , power_off_mock , get_conn_mock , get_mac_addr_mock ) : #NEWLINE# #INDENT# info = ssh . _parse_driver_info ( self . node ) #NEWLINE# info [ 'macs' ] = [ '11:11:11:11:11:11' , '52:54:00:cf:2d:31' ] #NEWLINE# get_mac_addr_mock . return_value = info [ 'macs' ] #NEWLINE# get_conn_mock . return_value = self . sshclient #NEWLINE# power_off_mock . return_value = states . POWER_OFF #NEWLINE# with mock . patch . object ( ssh , '_parse_driver_info' , autospec = True ) as parse_drv_info_mock : #NEWLINE# #INDENT# parse_drv_info_mock . return_value = info #NEWLINE# with task_manager . acquire ( self . context , info [ 'uuid' ] , shared = False ) as task : #NEWLINE# #INDENT# task . driver . power . set_power_state ( task , states . POWER_OFF ) #NEWLINE# parse_drv_info_mock . assert_called_once_with ( task . node ) #NEWLINE# get_mac_addr_mock . assert_called_once_with ( mock . ANY ) #NEWLINE# get_conn_mock . assert_called_once_with ( task . node ) #NEWLINE# power_off_mock . assert_called_once_with ( parse_drv_info_mock . sshclient , info )