Ejemplo n.º 1
0
    def test_power_query_retires_on_kg_error(self):
        context = make_context()
        k_g = context.pop("k_g", factory.make_name("k_g"))
        ipmi_power_driver = IPMIPowerDriver()
        mock_issue_ipmi_command = self.patch(ipmi_power_driver,
                                             "_issue_ipmi_command")
        k_g_error = IPMI_ERRORS["k_g invalid"]
        mock_issue_ipmi_command.side_effect = (
            k_g_error["exception"](k_g_error["message"]),
            None,
        )
        system_id = factory.make_name("system_id")

        ipmi_power_driver.power_query(system_id, {"k_g": k_g, **context})

        self.assertThat(
            mock_issue_ipmi_command,
            MockCallsMatch(
                call("query", **{
                    "k_g": k_g,
                    **context
                }),
                call("query", **context),
            ),
        )
Ejemplo n.º 2
0
    def test_power_query_calls__issue_ipmi_command(self):
        context = make_context()
        ipmi_power_driver = IPMIPowerDriver()
        _issue_ipmi_command_mock = self.patch(ipmi_power_driver,
                                              "_issue_ipmi_command")
        system_id = factory.make_name("system_id")
        ipmi_power_driver.power_query(system_id, context)

        self.assertThat(_issue_ipmi_command_mock,
                        MockCalledOnceWith("query", **context))