def test_powershell_encode_cmd(shell): """ Test cmd.powershell with encode_cmd """ ret = cmdmod.powershell('Write-Output "encoded foo"', encode_cmd=True, shell=shell) assert ret == "encoded foo"
def test_powershell_empty(): """ Tests cmd.powershell when the output is an empty string """ mock_run = {"pid": 1234, "retcode": 0, "stderr": "", "stdout": ""} with patch("salt.modules.cmdmod._run", return_value=mock_run): ret = cmdmod.powershell("Set-ExecutionPolicy RemoteSigned") assert ret == {}
def test_powershell(): """ Tests cmd.powershell with a string value output """ mock_run = {"pid": 1234, "retcode": 0, "stderr": "", "stdout": '"foo"'} with patch("salt.modules.cmdmod._run", return_value=mock_run): ret = cmdmod.powershell("Set-ExecutionPolicy RemoteSigned") assert ret == "foo"
def test_powershell(shell): """ Test cmd.powershell """ ret = cmdmod.powershell("Write-Output foo", shell=shell) assert ret == "foo"