MCPcopy
hub / github.com/saltstack/salt / test_modules

Function test_modules

tests/pytests/unit/modules/test_syslog_ng.py:291–310  ·  view source on GitHub ↗
(_modules, version_output, orig_env, bin_dir, mocked_env)

Source from the content-addressed store, hash-verified

289
290@pytest.mark.skip_on_windows(reason="Module not available on Windows")
291def test_modules(_modules, version_output, orig_env, bin_dir, mocked_env):
292 cmd_ret = {"retcode": 0, "stdout": version_output}
293 expected_output = {"retcode": 0, "stdout": _modules}
294 cmd_args = ["syslog-ng", "-V"]
295
296 cmd_mock = MagicMock(return_value=cmd_ret)
297 with patch.dict(syslog_ng.__salt__, {"cmd.run_all": cmd_mock}), patch.dict(
298 os.environ, orig_env
299 ):
300 result = syslog_ng.modules()
301 assert result == expected_output
302 cmd_mock.assert_called_once_with(cmd_args, env=None, python_shell=False)
303
304 cmd_mock = MagicMock(return_value=cmd_ret)
305 with patch.dict(syslog_ng.__salt__, {"cmd.run_all": cmd_mock}), patch.dict(
306 os.environ, orig_env
307 ):
308 result = syslog_ng.modules(syslog_ng_sbin_dir=bin_dir)
309 assert result == expected_output
310 cmd_mock.assert_called_once_with(cmd_args, env=mocked_env, python_shell=False)
311
312
313@pytest.mark.skip_on_windows(reason="Module not available on Windows")

Callers

nothing calls this directly

Calls 1

modulesMethod · 0.80

Tested by

no test coverage detected