def test_power_on_powers_on_with_wsman_when_already_off(self): amt_power_driver = AMTPowerDriver() context = make_context() _get_amt_command_mock = self.patch( amt_power_driver, "_get_amt_command" ) _get_amt_command_mock.return_value = "wsman" wsman_query_state_mock = self.patch( amt_power_driver, "wsman_query_state" ) wsman_query_state_mock.return_value = "off" wsman_power_on_mock = self.patch(amt_power_driver, "wsman_power_on") amt_power_driver.power_on(context["system_id"], context) self.expectThat( _get_amt_command_mock, MockCalledOnceWith(context["ip_address"], context["power_pass"]), ) self.expectThat( wsman_query_state_mock, MockCalledOnceWith(context["ip_address"], context["power_pass"]), ) self.expectThat( wsman_power_on_mock, MockCalledOnceWith(context["ip_address"], context["power_pass"]), )
def test_power_on_powers_on_with_amttool_when_already_on(self): amt_power_driver = AMTPowerDriver() context = make_context() _get_amt_command_mock = self.patch( amt_power_driver, "_get_amt_command" ) _get_amt_command_mock.return_value = "amttool" amttool_query_state_mock = self.patch( amt_power_driver, "amttool_query_state" ) amttool_query_state_mock.return_value = "on" amttool_restart_mock = self.patch(amt_power_driver, "amttool_restart") amt_power_driver.power_on(context["system_id"], context) self.expectThat( _get_amt_command_mock, MockCalledOnceWith(context["ip_address"], context["power_pass"]), ) self.expectThat( amttool_query_state_mock, MockCalledOnceWith(context["ip_address"], context["power_pass"]), ) self.expectThat( amttool_restart_mock, MockCalledOnceWith( context["ip_address"], context["power_pass"], context["boot_mode"], ), )
def test_power_on_powers_on_with_wsman_when_already_off(self): amt_power_driver = AMTPowerDriver() context = make_context() _get_amt_command_mock = self.patch(amt_power_driver, '_get_amt_command') _get_amt_command_mock.return_value = 'wsman' wsman_query_state_mock = self.patch(amt_power_driver, 'wsman_query_state') wsman_query_state_mock.return_value = 'off' wsman_power_on_mock = self.patch(amt_power_driver, 'wsman_power_on') amt_power_driver.power_on(context['system_id'], context) self.expectThat( _get_amt_command_mock, MockCalledOnceWith(context['ip_address'], context['power_pass'])) self.expectThat( wsman_query_state_mock, MockCalledOnceWith(context['ip_address'], context['power_pass'])) self.expectThat( wsman_power_on_mock, MockCalledOnceWith(context['ip_address'], context['power_pass']))
def test_power_on_powers_on_with_amttool_when_already_on(self): amt_power_driver = AMTPowerDriver() context = make_context() _get_amt_command_mock = self.patch(amt_power_driver, '_get_amt_command') _get_amt_command_mock.return_value = 'amttool' amttool_query_state_mock = self.patch(amt_power_driver, 'amttool_query_state') amttool_query_state_mock.return_value = 'on' amttool_restart_mock = self.patch(amt_power_driver, 'amttool_restart') amt_power_driver.power_on(context['system_id'], context) self.expectThat( _get_amt_command_mock, MockCalledOnceWith(context['ip_address'], context['power_pass'])) self.expectThat( amttool_query_state_mock, MockCalledOnceWith(context['ip_address'], context['power_pass'])) self.expectThat( amttool_restart_mock, MockCalledOnceWith(context['ip_address'], context['power_pass'], context['boot_mode']))