def test_config_test_cfgfile(self): cfgfile = '/path/to/syslog-ng.conf' cmd_ret = {'retcode': 1, 'stderr': 'Syntax error...', 'stdout': ''} cmd_args = ['syslog-ng', '--syntax-only', '--cfgfile={0}'.format(cfgfile)] cmd_mock = MagicMock(return_value=cmd_ret) with patch.dict(syslog_ng.__salt__, {'cmd.run_all': cmd_mock}), \ patch.dict(os.environ, self.orig_env): self.assertEqual(syslog_ng.config_test(cfgfile=cfgfile), cmd_ret) cmd_mock.assert_called_once_with( cmd_args, env=None, python_shell=False ) cmd_mock = MagicMock(return_value=cmd_ret) with patch.dict(syslog_ng.__salt__, {'cmd.run_all': cmd_mock}), \ patch.dict(os.environ, self.orig_env): self.assertEqual( syslog_ng.config_test( syslog_ng_sbin_dir=self.bin_dir, cfgfile=cfgfile ), cmd_ret ) cmd_mock.assert_called_once_with( cmd_args, env=self.mocked_env, python_shell=False )
def test_config_test_cfgfile(self): cfgfile = "/path/to/syslog-ng.conf" cmd_ret = {"retcode": 1, "stderr": "Syntax error...", "stdout": ""} cmd_args = [ "syslog-ng", "--syntax-only", "--cfgfile={}".format(cfgfile) ] cmd_mock = MagicMock(return_value=cmd_ret) with patch.dict(syslog_ng.__salt__, {"cmd.run_all": cmd_mock}), patch.dict( os.environ, self.orig_env): self.assertEqual(syslog_ng.config_test(cfgfile=cfgfile), cmd_ret) cmd_mock.assert_called_once_with(cmd_args, env=None, python_shell=False) cmd_mock = MagicMock(return_value=cmd_ret) with patch.dict(syslog_ng.__salt__, {"cmd.run_all": cmd_mock}), patch.dict( os.environ, self.orig_env): self.assertEqual( syslog_ng.config_test(syslog_ng_sbin_dir=self.bin_dir, cfgfile=cfgfile), cmd_ret, ) cmd_mock.assert_called_once_with(cmd_args, env=self.mocked_env, python_shell=False)
def test_config_test(self): cmd_ret = {'retcode': 0, 'stderr': '', 'stdout': 'Foo'} cmd_args = ['syslog-ng', '--syntax-only'] cmd_mock = MagicMock(return_value=cmd_ret) with patch.dict(syslog_ng.__salt__, {'cmd.run_all': cmd_mock}), \ patch.dict(os.environ, self.orig_env): result = syslog_ng.config_test() self.assertEqual(result, cmd_ret) cmd_mock.assert_called_once_with( cmd_args, env=None, python_shell=False ) cmd_mock = MagicMock(return_value=cmd_ret) with patch.dict(syslog_ng.__salt__, {'cmd.run_all': cmd_mock}), \ patch.dict(os.environ, self.orig_env): result = syslog_ng.config_test(syslog_ng_sbin_dir=self.bin_dir) self.assertEqual(result, cmd_ret) cmd_mock.assert_called_once_with( cmd_args, env=self.mocked_env, python_shell=False )
def test_config_test(self): cmd_ret = {"retcode": 0, "stderr": "", "stdout": "Foo"} cmd_args = ["syslog-ng", "--syntax-only"] cmd_mock = MagicMock(return_value=cmd_ret) with patch.dict(syslog_ng.__salt__, {"cmd.run_all": cmd_mock}), patch.dict( os.environ, self.orig_env): result = syslog_ng.config_test() self.assertEqual(result, cmd_ret) cmd_mock.assert_called_once_with(cmd_args, env=None, python_shell=False) cmd_mock = MagicMock(return_value=cmd_ret) with patch.dict(syslog_ng.__salt__, {"cmd.run_all": cmd_mock}), patch.dict( os.environ, self.orig_env): result = syslog_ng.config_test(syslog_ng_sbin_dir=self.bin_dir) self.assertEqual(result, cmd_ret) cmd_mock.assert_called_once_with(cmd_args, env=self.mocked_env, python_shell=False)