From 8306db2a3c040c51817ba7cb832a6361a1443861 Mon Sep 17 00:00:00 2001 From: cmcmarrow Date: Thu, 16 May 2019 15:51:21 -0700 Subject: [PATCH 01/12] Listen to extra flags when running pkg.installed. --- salt/modules/win_pkg.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/salt/modules/win_pkg.py b/salt/modules/win_pkg.py index 8ef4bae6ceb3..45c04fcf24a5 100644 --- a/salt/modules/win_pkg.py +++ b/salt/modules/win_pkg.py @@ -1188,6 +1188,9 @@ def install(name=None, refresh=False, pkgs=None, **kwargs): 'extra_install_flags': kwargs.get('extra_install_flags') } } + elif len(pkg_params) == 1: + for pkg in pkg_params: + pkg_params[pkg]['extra_install_flags'] = kwargs.get('extra_install_flags') # Get a list of currently installed software for comparison at the end old = list_pkgs(saltenv=saltenv, refresh=refresh, versions_as_list=True) From c474879c57e995b24d08f0b9d828e46a518998e7 Mon Sep 17 00:00:00 2001 From: cmcmarrow Date: Fri, 17 May 2019 10:43:43 -0700 Subject: [PATCH 02/12] listen to extra flags when running pkg.install --- salt/modules/win_pkg.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/salt/modules/win_pkg.py b/salt/modules/win_pkg.py index 45c04fcf24a5..38e98c3a6d6a 100644 --- a/salt/modules/win_pkg.py +++ b/salt/modules/win_pkg.py @@ -1189,8 +1189,9 @@ def install(name=None, refresh=False, pkgs=None, **kwargs): } } elif len(pkg_params) == 1: - for pkg in pkg_params: - pkg_params[pkg]['extra_install_flags'] = kwargs.get('extra_install_flags') + # A dict of packages was passed, but it contains only 1 key, so we need + # to add the 'extra_install_flags' + pkg_params[pkgs[0]]['extra_install_flags'] = kwargs.get('extra_install_flags') # Get a list of currently installed software for comparison at the end old = list_pkgs(saltenv=saltenv, refresh=refresh, versions_as_list=True) From 23cc72336be4d00405ae86828a0bdd5115f362f1 Mon Sep 17 00:00:00 2001 From: cmcmarrow Date: Fri, 17 May 2019 12:17:20 -0700 Subject: [PATCH 03/12] listen to extra flags when running pkg.installed --- salt/modules/win_pkg.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/salt/modules/win_pkg.py b/salt/modules/win_pkg.py index 38e98c3a6d6a..0cbc16237a75 100644 --- a/salt/modules/win_pkg.py +++ b/salt/modules/win_pkg.py @@ -1191,7 +1191,8 @@ def install(name=None, refresh=False, pkgs=None, **kwargs): elif len(pkg_params) == 1: # A dict of packages was passed, but it contains only 1 key, so we need # to add the 'extra_install_flags' - pkg_params[pkgs[0]]['extra_install_flags'] = kwargs.get('extra_install_flags') + for pkg in pkg_params: + pkg_params[pkg]['extra_install_flags'] = kwargs.get('extra_install_flags') # Get a list of currently installed software for comparison at the end old = list_pkgs(saltenv=saltenv, refresh=refresh, versions_as_list=True) From e104cbf81abbe636a965a144cc240ffa8edc462e Mon Sep 17 00:00:00 2001 From: cmcmarrow Date: Mon, 20 May 2019 13:44:22 -0700 Subject: [PATCH 04/12] listen to extra_install_flags and test --- tests/unit/modules/test_win_pkg.py | 72 ++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/tests/unit/modules/test_win_pkg.py b/tests/unit/modules/test_win_pkg.py index 50881a634845..0467cfc9549b 100644 --- a/tests/unit/modules/test_win_pkg.py +++ b/tests/unit/modules/test_win_pkg.py @@ -15,6 +15,9 @@ import salt.modules.pkg_resource as pkg_resource import salt.modules.win_pkg as win_pkg +# Import third party libs +import salt.utils.data + class WinPkgInstallTestCase(TestCase, LoaderModuleMockMixin): ''' @@ -151,3 +154,72 @@ def test_pkg_install_existing_with_version(self): expected = {} result = win_pkg.install(name='nsis', version='3.03') self.assertDictEqual(expected, result) + + @staticmethod + def test_name_pkg_install(): + ''' + test pkg.install name extra_install_flags + ''' + + ret__get_package_info = {'3.03': {'uninstaller': '%program.exe', 'reboot': False, + 'msiexec': False, + 'installer': 'runme.exe', + 'uninstall_flags': '/S', 'locale': 'en_US', 'install_flags': '/s', + 'full_name': 'Firebox 3.03 (x86 en-US)'}} + + mock = MagicMock(return_value={'retcode': 0}) + with patch.object(salt.utils.data, 'is_true', MagicMock(return_value=True)),\ + patch.object(win_pkg, '_get_package_info', MagicMock(return_value=ret__get_package_info)),\ + patch.dict(win_pkg.__salt__, {'pkg_resource.parse_targets': + MagicMock(return_value=[{'firebox': '3.03'}, None]), + 'cp.is_cached': + MagicMock(return_value='C:\\fake\\path.exe'), + 'cmd.run_all': mock}): + ret = win_pkg.install(name='firebox', version='3.03', extra_install_flags='-e True') + mock.assert_called_once_with('"C:\\Windows\\system32\\cmd.exe" /s /c ""runme.exe" /s -e True"', + '', output_loglevel='trace', python_shell=False, redirect_stderr=True) + + @staticmethod + def test_single_pkg_install(): + ''' + test pkg.install pkg with extra_install_flags + ''' + ret__get_package_info = {'3.03': {'uninstaller': '%program.exe', 'reboot': False, + 'msiexec': False, + 'installer': 'runme.exe', + 'uninstall_flags': '/S', 'locale': 'en_US', 'install_flags': '/s', + 'full_name': 'Firebox 3.03 (x86 en-US)'}} + + mock = MagicMock(return_value={'retcode': 0}) + with patch.object(salt.utils.data, 'is_true', MagicMock(return_value=True)), \ + patch.object(win_pkg, '_get_package_info', MagicMock(return_value=ret__get_package_info)), \ + patch.dict(win_pkg.__salt__, {'pkg_resource.parse_targets': + MagicMock(return_value=[{'firebox': '3.03'}, None]), + 'cp.is_cached': + MagicMock(return_value='C:\\fake\\path.exe'), + 'cmd.run_all': mock}): + ret = win_pkg.install(pkgs=['firebox'], version='3.03', extra_install_flags='-e True') + mock.assert_called_once_with('"C:\\Windows\\system32\\cmd.exe" /s /c ""runme.exe" /s -e True"', + '', output_loglevel='trace', python_shell=False, redirect_stderr=True) + + def test_multiple_pkg_install(self): + ''' + test pkg.install pkg with extra_install_flags + ''' + ret__get_package_info = {'3.03': {'uninstaller': '%program.exe', 'reboot': False, + 'msiexec': False, + 'installer': 'runme.exe', + 'uninstall_flags': '/S', 'locale': 'en_US', 'install_flags': '/s', + 'full_name': 'Firebox 3.03 (x86 en-US)'}} + + mock = MagicMock(return_value={'retcode': 0}) + with patch.object(salt.utils.data, 'is_true', MagicMock(return_value=True)), \ + patch.object(win_pkg, '_get_package_info', MagicMock(return_value=ret__get_package_info)), \ + patch.dict(win_pkg.__salt__, {'pkg_resource.parse_targets': + MagicMock(return_value=[{'firebox': '3.03', 'got': '3.03'}, None]), + 'cp.is_cached': + MagicMock(return_value='C:\\fake\\path.exe'), + 'cmd.run_all': mock}): + ret = win_pkg.install(pkgs=['firebox', 'got'], extra_install_flags='-e True') + mock.assert_called_with('"C:\\Windows\\system32\\cmd.exe" /s /c ""runme.exe" /s"', + '', output_loglevel='trace', python_shell=False, redirect_stderr=True) From 68e1e2e25926701af99b65cd8402f38c704a606d Mon Sep 17 00:00:00 2001 From: Charles McMarrow <48689152+cmcmarrow@users.noreply.github.com> Date: Mon, 20 May 2019 14:48:56 -0600 Subject: [PATCH 05/12] Update test_win_pkg.py --- tests/unit/modules/test_win_pkg.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/unit/modules/test_win_pkg.py b/tests/unit/modules/test_win_pkg.py index 0467cfc9549b..51c03e6f38b8 100644 --- a/tests/unit/modules/test_win_pkg.py +++ b/tests/unit/modules/test_win_pkg.py @@ -14,8 +14,6 @@ # Import Salt Libs import salt.modules.pkg_resource as pkg_resource import salt.modules.win_pkg as win_pkg - -# Import third party libs import salt.utils.data From 10d8654bd1d461e0c858e1bd2df977ebe2a06f17 Mon Sep 17 00:00:00 2001 From: cmcmarrow Date: Mon, 20 May 2019 13:54:59 -0700 Subject: [PATCH 06/12] listen to extra_install_flags and test --- salt/modules/win_pkg.py | 3 +-- tests/unit/modules/test_win_pkg.py | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/salt/modules/win_pkg.py b/salt/modules/win_pkg.py index 0cbc16237a75..38e98c3a6d6a 100644 --- a/salt/modules/win_pkg.py +++ b/salt/modules/win_pkg.py @@ -1191,8 +1191,7 @@ def install(name=None, refresh=False, pkgs=None, **kwargs): elif len(pkg_params) == 1: # A dict of packages was passed, but it contains only 1 key, so we need # to add the 'extra_install_flags' - for pkg in pkg_params: - pkg_params[pkg]['extra_install_flags'] = kwargs.get('extra_install_flags') + pkg_params[pkgs[0]]['extra_install_flags'] = kwargs.get('extra_install_flags') # Get a list of currently installed software for comparison at the end old = list_pkgs(saltenv=saltenv, refresh=refresh, versions_as_list=True) diff --git a/tests/unit/modules/test_win_pkg.py b/tests/unit/modules/test_win_pkg.py index 0467cfc9549b..51c03e6f38b8 100644 --- a/tests/unit/modules/test_win_pkg.py +++ b/tests/unit/modules/test_win_pkg.py @@ -14,8 +14,6 @@ # Import Salt Libs import salt.modules.pkg_resource as pkg_resource import salt.modules.win_pkg as win_pkg - -# Import third party libs import salt.utils.data From 7b18f9de83c72b3dfea083c80c66c2e1bae603fc Mon Sep 17 00:00:00 2001 From: cmcmarrow Date: Mon, 20 May 2019 14:44:50 -0700 Subject: [PATCH 07/12] listen to extra_install_flags and test --- salt/modules/win_pkg.py | 3 ++- tests/unit/modules/test_win_pkg.py | 21 ++++++++------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/salt/modules/win_pkg.py b/salt/modules/win_pkg.py index 38e98c3a6d6a..0cbc16237a75 100644 --- a/salt/modules/win_pkg.py +++ b/salt/modules/win_pkg.py @@ -1191,7 +1191,8 @@ def install(name=None, refresh=False, pkgs=None, **kwargs): elif len(pkg_params) == 1: # A dict of packages was passed, but it contains only 1 key, so we need # to add the 'extra_install_flags' - pkg_params[pkgs[0]]['extra_install_flags'] = kwargs.get('extra_install_flags') + for pkg in pkg_params: + pkg_params[pkg]['extra_install_flags'] = kwargs.get('extra_install_flags') # Get a list of currently installed software for comparison at the end old = list_pkgs(saltenv=saltenv, refresh=refresh, versions_as_list=True) diff --git a/tests/unit/modules/test_win_pkg.py b/tests/unit/modules/test_win_pkg.py index 51c03e6f38b8..12e12290a559 100644 --- a/tests/unit/modules/test_win_pkg.py +++ b/tests/unit/modules/test_win_pkg.py @@ -153,8 +153,7 @@ def test_pkg_install_existing_with_version(self): result = win_pkg.install(name='nsis', version='3.03') self.assertDictEqual(expected, result) - @staticmethod - def test_name_pkg_install(): + def test_name_pkg_install(self): ''' test pkg.install name extra_install_flags ''' @@ -173,12 +172,10 @@ def test_name_pkg_install(): 'cp.is_cached': MagicMock(return_value='C:\\fake\\path.exe'), 'cmd.run_all': mock}): - ret = win_pkg.install(name='firebox', version='3.03', extra_install_flags='-e True') - mock.assert_called_once_with('"C:\\Windows\\system32\\cmd.exe" /s /c ""runme.exe" /s -e True"', - '', output_loglevel='trace', python_shell=False, redirect_stderr=True) + ret = win_pkg.install(name='firebox', version='3.03', extra_install_flags='-e True -test_flag True') + self.assertEqual('-e True -test_flag True' in str(mock.call_args[0]), True) - @staticmethod - def test_single_pkg_install(): + def test_single_pkg_install(self): ''' test pkg.install pkg with extra_install_flags ''' @@ -196,9 +193,8 @@ def test_single_pkg_install(): 'cp.is_cached': MagicMock(return_value='C:\\fake\\path.exe'), 'cmd.run_all': mock}): - ret = win_pkg.install(pkgs=['firebox'], version='3.03', extra_install_flags='-e True') - mock.assert_called_once_with('"C:\\Windows\\system32\\cmd.exe" /s /c ""runme.exe" /s -e True"', - '', output_loglevel='trace', python_shell=False, redirect_stderr=True) + ret = win_pkg.install(pkgs=['firebox'], version='3.03', extra_install_flags='-e True -test_flag True') + self.assertEqual('-e True -test_flag True' in str(mock.call_args[0]), True) def test_multiple_pkg_install(self): ''' @@ -218,6 +214,5 @@ def test_multiple_pkg_install(self): 'cp.is_cached': MagicMock(return_value='C:\\fake\\path.exe'), 'cmd.run_all': mock}): - ret = win_pkg.install(pkgs=['firebox', 'got'], extra_install_flags='-e True') - mock.assert_called_with('"C:\\Windows\\system32\\cmd.exe" /s /c ""runme.exe" /s"', - '', output_loglevel='trace', python_shell=False, redirect_stderr=True) + ret = win_pkg.install(pkgs=['firebox', 'got'], extra_install_flags='-e True -test_flag True') + self.assertEqual('-e True -test_flag True' in str(mock.call_args[0]), False) From 92b5c424fbad2d54cf9bb0770bdc94f2e83ae0c1 Mon Sep 17 00:00:00 2001 From: cmcmarrow Date: Mon, 20 May 2019 14:57:18 -0700 Subject: [PATCH 08/12] listen to extra_install_flag fix and test --- tests/unit/modules/test_win_pkg.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/unit/modules/test_win_pkg.py b/tests/unit/modules/test_win_pkg.py index 12e12290a559..f0ee1ed8f7dc 100644 --- a/tests/unit/modules/test_win_pkg.py +++ b/tests/unit/modules/test_win_pkg.py @@ -9,14 +9,16 @@ # Import Salt Testing Libs from tests.support.mixins import LoaderModuleMockMixin from tests.support.mock import MagicMock, patch -from tests.support.unit import TestCase +from tests.support.unit import TestCase, skipIf # Import Salt Libs import salt.modules.pkg_resource as pkg_resource import salt.modules.win_pkg as win_pkg import salt.utils.data +import salt.utils.platform +@skipIf(not salt.utils.platform.is_windows(), "Must be on Windows") class WinPkgInstallTestCase(TestCase, LoaderModuleMockMixin): ''' Test cases for salt.modules.win_pkg From 48d8f2722c2c0bdd9bf5d0b71d84448981a85351 Mon Sep 17 00:00:00 2001 From: cmcmarrow Date: Mon, 20 May 2019 15:27:51 -0700 Subject: [PATCH 09/12] listen to extra_install_flag fix and test --- tests/unit/modules/test_win_pkg.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/unit/modules/test_win_pkg.py b/tests/unit/modules/test_win_pkg.py index f0ee1ed8f7dc..bcccdc7834cd 100644 --- a/tests/unit/modules/test_win_pkg.py +++ b/tests/unit/modules/test_win_pkg.py @@ -166,16 +166,16 @@ def test_name_pkg_install(self): 'uninstall_flags': '/S', 'locale': 'en_US', 'install_flags': '/s', 'full_name': 'Firebox 3.03 (x86 en-US)'}} - mock = MagicMock(return_value={'retcode': 0}) + ret_cmd_run_all = MagicMock(return_value={'retcode': 0}) with patch.object(salt.utils.data, 'is_true', MagicMock(return_value=True)),\ patch.object(win_pkg, '_get_package_info', MagicMock(return_value=ret__get_package_info)),\ patch.dict(win_pkg.__salt__, {'pkg_resource.parse_targets': - MagicMock(return_value=[{'firebox': '3.03'}, None]), + MagicMock(return_value=[{'firebox': '3.03'}, None]), 'cp.is_cached': - MagicMock(return_value='C:\\fake\\path.exe'), - 'cmd.run_all': mock}): + MagicMock(return_value='C:\\fake\\path.exe'), + 'cmd.run_all': ret_cmd_run_all}): ret = win_pkg.install(name='firebox', version='3.03', extra_install_flags='-e True -test_flag True') - self.assertEqual('-e True -test_flag True' in str(mock.call_args[0]), True) + self.assertTrue('-e True -test_flag True' in str(ret_cmd_run_all.call_args[0])) def test_single_pkg_install(self): ''' @@ -187,16 +187,16 @@ def test_single_pkg_install(self): 'uninstall_flags': '/S', 'locale': 'en_US', 'install_flags': '/s', 'full_name': 'Firebox 3.03 (x86 en-US)'}} - mock = MagicMock(return_value={'retcode': 0}) + ret_cmd_run_all = MagicMock(return_value={'retcode': 0}) with patch.object(salt.utils.data, 'is_true', MagicMock(return_value=True)), \ patch.object(win_pkg, '_get_package_info', MagicMock(return_value=ret__get_package_info)), \ patch.dict(win_pkg.__salt__, {'pkg_resource.parse_targets': MagicMock(return_value=[{'firebox': '3.03'}, None]), 'cp.is_cached': MagicMock(return_value='C:\\fake\\path.exe'), - 'cmd.run_all': mock}): + 'cmd.run_all': ret_cmd_run_all}): ret = win_pkg.install(pkgs=['firebox'], version='3.03', extra_install_flags='-e True -test_flag True') - self.assertEqual('-e True -test_flag True' in str(mock.call_args[0]), True) + self.assertTrue('-e True -test_flag True' in str(ret_cmd_run_all.call_args[0])) def test_multiple_pkg_install(self): ''' @@ -208,13 +208,13 @@ def test_multiple_pkg_install(self): 'uninstall_flags': '/S', 'locale': 'en_US', 'install_flags': '/s', 'full_name': 'Firebox 3.03 (x86 en-US)'}} - mock = MagicMock(return_value={'retcode': 0}) + ret_cmd_run_all = MagicMock(return_value={'retcode': 0}) with patch.object(salt.utils.data, 'is_true', MagicMock(return_value=True)), \ patch.object(win_pkg, '_get_package_info', MagicMock(return_value=ret__get_package_info)), \ patch.dict(win_pkg.__salt__, {'pkg_resource.parse_targets': MagicMock(return_value=[{'firebox': '3.03', 'got': '3.03'}, None]), 'cp.is_cached': MagicMock(return_value='C:\\fake\\path.exe'), - 'cmd.run_all': mock}): + 'cmd.run_all': ret_cmd_run_all}): ret = win_pkg.install(pkgs=['firebox', 'got'], extra_install_flags='-e True -test_flag True') - self.assertEqual('-e True -test_flag True' in str(mock.call_args[0]), False) + self.assertFalse('-e True -test_flag True' in str(ret_cmd_run_all.call_args[0])) From 91a5cbd3f0dfbcbb476d1185ead3878b76524d4d Mon Sep 17 00:00:00 2001 From: cmcmarrow Date: Mon, 20 May 2019 15:30:49 -0700 Subject: [PATCH 10/12] listen to extra_install_flag fix and test --- tests/unit/modules/test_win_pkg.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/modules/test_win_pkg.py b/tests/unit/modules/test_win_pkg.py index bcccdc7834cd..1650e40a6b47 100644 --- a/tests/unit/modules/test_win_pkg.py +++ b/tests/unit/modules/test_win_pkg.py @@ -155,7 +155,7 @@ def test_pkg_install_existing_with_version(self): result = win_pkg.install(name='nsis', version='3.03') self.assertDictEqual(expected, result) - def test_name_pkg_install(self): + def test_pkg_install_name(self): ''' test pkg.install name extra_install_flags ''' @@ -177,7 +177,7 @@ def test_name_pkg_install(self): ret = win_pkg.install(name='firebox', version='3.03', extra_install_flags='-e True -test_flag True') self.assertTrue('-e True -test_flag True' in str(ret_cmd_run_all.call_args[0])) - def test_single_pkg_install(self): + def test_pkg_install_single_pkg(self): ''' test pkg.install pkg with extra_install_flags ''' @@ -198,7 +198,7 @@ def test_single_pkg_install(self): ret = win_pkg.install(pkgs=['firebox'], version='3.03', extra_install_flags='-e True -test_flag True') self.assertTrue('-e True -test_flag True' in str(ret_cmd_run_all.call_args[0])) - def test_multiple_pkg_install(self): + def test_pkg_install_multiple_pkgs(self): ''' test pkg.install pkg with extra_install_flags ''' From 3f651cfd86420b7d9c64a9406c5cb2505dedfe69 Mon Sep 17 00:00:00 2001 From: Charles McMarrow <48689152+cmcmarrow@users.noreply.github.com> Date: Mon, 20 May 2019 16:47:40 -0600 Subject: [PATCH 11/12] Update test_win_pkg.py --- tests/unit/modules/test_win_pkg.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/unit/modules/test_win_pkg.py b/tests/unit/modules/test_win_pkg.py index 1650e40a6b47..17a3b8491068 100644 --- a/tests/unit/modules/test_win_pkg.py +++ b/tests/unit/modules/test_win_pkg.py @@ -166,16 +166,16 @@ def test_pkg_install_name(self): 'uninstall_flags': '/S', 'locale': 'en_US', 'install_flags': '/s', 'full_name': 'Firebox 3.03 (x86 en-US)'}} - ret_cmd_run_all = MagicMock(return_value={'retcode': 0}) + mock_cmd_run_all = MagicMock(return_value={'retcode': 0}) with patch.object(salt.utils.data, 'is_true', MagicMock(return_value=True)),\ patch.object(win_pkg, '_get_package_info', MagicMock(return_value=ret__get_package_info)),\ patch.dict(win_pkg.__salt__, {'pkg_resource.parse_targets': MagicMock(return_value=[{'firebox': '3.03'}, None]), 'cp.is_cached': MagicMock(return_value='C:\\fake\\path.exe'), - 'cmd.run_all': ret_cmd_run_all}): + 'cmd.run_all': mock_cmd_run_all}): ret = win_pkg.install(name='firebox', version='3.03', extra_install_flags='-e True -test_flag True') - self.assertTrue('-e True -test_flag True' in str(ret_cmd_run_all.call_args[0])) + self.assertTrue('-e True -test_flag True' in str(mock_cmd_run_all.call_args[0])) def test_pkg_install_single_pkg(self): ''' @@ -187,16 +187,16 @@ def test_pkg_install_single_pkg(self): 'uninstall_flags': '/S', 'locale': 'en_US', 'install_flags': '/s', 'full_name': 'Firebox 3.03 (x86 en-US)'}} - ret_cmd_run_all = MagicMock(return_value={'retcode': 0}) + mock_cmd_run_all = MagicMock(return_value={'retcode': 0}) with patch.object(salt.utils.data, 'is_true', MagicMock(return_value=True)), \ patch.object(win_pkg, '_get_package_info', MagicMock(return_value=ret__get_package_info)), \ patch.dict(win_pkg.__salt__, {'pkg_resource.parse_targets': MagicMock(return_value=[{'firebox': '3.03'}, None]), 'cp.is_cached': MagicMock(return_value='C:\\fake\\path.exe'), - 'cmd.run_all': ret_cmd_run_all}): + 'cmd.run_all': mock_cmd_run_all}): ret = win_pkg.install(pkgs=['firebox'], version='3.03', extra_install_flags='-e True -test_flag True') - self.assertTrue('-e True -test_flag True' in str(ret_cmd_run_all.call_args[0])) + self.assertTrue('-e True -test_flag True' in str(mock_cmd_run_all.call_args[0])) def test_pkg_install_multiple_pkgs(self): ''' @@ -208,13 +208,13 @@ def test_pkg_install_multiple_pkgs(self): 'uninstall_flags': '/S', 'locale': 'en_US', 'install_flags': '/s', 'full_name': 'Firebox 3.03 (x86 en-US)'}} - ret_cmd_run_all = MagicMock(return_value={'retcode': 0}) + mock_cmd_run_all = MagicMock(return_value={'retcode': 0}) with patch.object(salt.utils.data, 'is_true', MagicMock(return_value=True)), \ patch.object(win_pkg, '_get_package_info', MagicMock(return_value=ret__get_package_info)), \ patch.dict(win_pkg.__salt__, {'pkg_resource.parse_targets': MagicMock(return_value=[{'firebox': '3.03', 'got': '3.03'}, None]), 'cp.is_cached': MagicMock(return_value='C:\\fake\\path.exe'), - 'cmd.run_all': ret_cmd_run_all}): + 'cmd.run_all': mock_cmd_run_all}): ret = win_pkg.install(pkgs=['firebox', 'got'], extra_install_flags='-e True -test_flag True') - self.assertFalse('-e True -test_flag True' in str(ret_cmd_run_all.call_args[0])) + self.assertFalse('-e True -test_flag True' in str(mock_cmd_run_all.call_args[0])) From f159c6e42c9e172e778e96f420bd34dde2febf1d Mon Sep 17 00:00:00 2001 From: Charles McMarrow <48689152+cmcmarrow@users.noreply.github.com> Date: Tue, 21 May 2019 10:06:06 -0600 Subject: [PATCH 12/12] Update test_win_pkg.py --- tests/unit/modules/test_win_pkg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/modules/test_win_pkg.py b/tests/unit/modules/test_win_pkg.py index 17a3b8491068..50cd3a8e1106 100644 --- a/tests/unit/modules/test_win_pkg.py +++ b/tests/unit/modules/test_win_pkg.py @@ -18,7 +18,7 @@ import salt.utils.platform -@skipIf(not salt.utils.platform.is_windows(), "Must be on Windows") +@skipIf(not salt.utils.platform.is_windows(), "Must be on Windows!") class WinPkgInstallTestCase(TestCase, LoaderModuleMockMixin): ''' Test cases for salt.modules.win_pkg