def test_set_strategy_invalid(): """ Test rebootmgr.strategy with invalid parameter """ salt_mock = { "cmd.run_all": MagicMock(return_value={ "stdout": "output", "retcode": 0 }) } with patch.dict(rebootmgr.__salt__, salt_mock): with pytest.raises(CommandExecutionError): rebootmgr.set_strategy("invalid")
def test_set_strategy(): """ Test rebootmgr.set_strategy with strategy parameter """ salt_mock = { "cmd.run_all": MagicMock(return_value={ "stdout": "output", "retcode": 0 }) } with patch.dict(rebootmgr.__salt__, salt_mock): assert rebootmgr.set_strategy("best-effort") == "output" salt_mock["cmd.run_all"].assert_called_with( ["rebootmgrctl", "set-strategy", "best-effort"])