From 1f497d8f78a6a711a7b8e70114c5a75556447d7e Mon Sep 17 00:00:00 2001 From: twangboy Date: Tue, 27 Jun 2017 16:43:54 -0600 Subject: [PATCH] Fix paths --- tests/unit/config/test_api.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/tests/unit/config/test_api.py b/tests/unit/config/test_api.py index ff0921faa4..faf2dc6300 100644 --- a/tests/unit/config/test_api.py +++ b/tests/unit/config/test_api.py @@ -18,12 +18,19 @@ from tests.support.mock import ( # Import Salt libs import salt.config +import salt.utils MOCK_MASTER_DEFAULT_OPTS = { 'log_file': '/var/log/salt/master', 'pidfile': '/var/run/salt-master.pid', 'root_dir': '/' } +if salt.utils.is_windows(): + MOCK_MASTER_DEFAULT_OPTS = { + 'log_file': 'c:\\salt\\var\\log\\salt\\master', + 'pidfile': 'c:\\salt\\var\\run\\salt-master.pid', + 'root_dir': 'c:\\salt' + } @skipIf(NO_MOCK, NO_MOCK_REASON) @@ -39,8 +46,13 @@ class APIConfigTestCase(TestCase): the DEFAULT_API_OPTS 'api_logfile' value. ''' with patch('salt.config.client_config', MagicMock(return_value=MOCK_MASTER_DEFAULT_OPTS)): + + expected = '/var/log/salt/api' + if salt.utils.is_windows(): + expected = 'c:\\salt\\var\\log\\salt\\api' + ret = salt.config.api_config('/some/fake/path') - self.assertEqual(ret['log_file'], '/var/log/salt/api') + self.assertEqual(ret['log_file'], expected) def test_api_config_pidfile_values(self): ''' @@ -49,8 +61,13 @@ class APIConfigTestCase(TestCase): the DEFAULT_API_OPTS 'api_pidfile' value. ''' with patch('salt.config.client_config', MagicMock(return_value=MOCK_MASTER_DEFAULT_OPTS)): + + expected = '/var/run/salt-api.pid' + if salt.utils.is_windows(): + expected = 'c:\\salt\\var\\run\\salt-api.pid' + ret = salt.config.api_config('/some/fake/path') - self.assertEqual(ret['pidfile'], '/var/run/salt-api.pid') + self.assertEqual(ret['pidfile'], expected) @destructiveTest def test_master_config_file_overrides_defaults(self): @@ -64,6 +81,10 @@ class APIConfigTestCase(TestCase): foo_dir = '/foo/bar/baz' hello_dir = '/hello/world' + if salt.utils.is_windows(): + foo_dir = 'c:\\foo\\bar\\baz' + hello_dir = 'c:\\hello\\world' + mock_master_config = { 'api_pidfile': foo_dir, 'api_logfile': hello_dir, @@ -100,6 +121,11 @@ class APIConfigTestCase(TestCase): mock_master_config = MOCK_MASTER_DEFAULT_OPTS.copy() mock_master_config['root_dir'] = '/mock/root/' + if salt.utils.is_windows(): + mock_log = 'c:\\mock\\root\\var\\log\\salt\\api' + mock_pid = 'c:\\mock\\root\\var\\run\\salt-api.pid' + mock_master_config['root_dir'] = 'c:\\mock\\root' + with patch('salt.config.client_config', MagicMock(return_value=mock_master_config)): ret = salt.config.api_config('/some/fake/path')