#NEWLINE# @ mock . patch . object ( processutils , 'ssh_execute' , autospec = True ) #NEWLINE# @ mock . patch . object ( ssh , '_get_power_status' , autospec = True ) #NEWLINE# @ mock . patch . object ( ssh , '_get_hosts_name_for_node' , autospec = True ) #NEWLINE# def test__power_off_good( self , get_hosts_name_mock , get_power_status_mock , exec_ssh_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_power_status_mock . side_effect = iter ( [ states . POWER_ON , states . POWER_OFF ] ) #NEWLINE# get_hosts_name_mock . return_value = 'NodeName' #NEWLINE# expected = [ mock . call ( self . sshclient , info ) , mock . call ( self . sshclient , info ) ] #NEWLINE# cmd_to_exec = ( '%s %s' % ( get_hosts_name_mock [ 'cmd_set' ] [ 'base_cmd' ] , info [ 'cmd_set' ] [ 'stop_cmd' ] ) ) #NEWLINE# cmd_to_exec = cmd_to_exec . replace ( '{_NodeName_}' , 'NodeName' ) #NEWLINE# current_state = ssh . _power_off ( self . sshclient , info ) #NEWLINE# self . assertEqual ( states . POWER_OFF , current_state ) #NEWLINE# self . assertEqual ( expected , get_power_status_mock . call_args_list ) #NEWLINE# get_hosts_name_mock . assert_called_once_with ( self . sshclient , info ) #NEWLINE# exec_ssh_mock . assert_called_once_with ( self . sshclient , cmd_to_exec )