mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Fixed the test_install_download_cache_argument_in_resulting_command
to accomodate introduced cache directory argument fixes and renamed it to test_install_download_cache_dir_arguments_in_resulting_command
.
This commit is contained in:
parent
9d0f94eeba
commit
4f23a23ca8
@ -681,7 +681,7 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914
|
||||
|
||||
if download_cache or cache_dir:
|
||||
cmd.extend(['--cache-dir' if salt.utils.compare_versions(
|
||||
ver1=version(bin_env), oper='>=', ver2='6.0.0'
|
||||
ver1=version(bin_env), oper='>=', ver2='6.0'
|
||||
) else '--download-cache', download_cache or cache_dir])
|
||||
|
||||
if source:
|
||||
|
@ -469,19 +469,38 @@ class PipTestCase(TestCase):
|
||||
python_shell=False,
|
||||
)
|
||||
|
||||
def test_install_download_cache_argument_in_resulting_command(self):
|
||||
def test_install_download_cache_dir_arguments_in_resulting_command(self):
|
||||
pkg = 'pep8'
|
||||
cache_dir_arg_mapping = {
|
||||
'1.5.6': '--download-cache',
|
||||
'6.0': '--cache-dir',
|
||||
}
|
||||
download_cache = '/tmp/foo'
|
||||
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
|
||||
|
||||
with patch.dict(pip.__salt__, {'cmd.run_all': mock}):
|
||||
pip.install(pkg, download_cache='/tmp/foo')
|
||||
mock.assert_called_once_with(
|
||||
['pip', 'install', '--download-cache', download_cache, pkg],
|
||||
saltenv='base',
|
||||
runas=None,
|
||||
use_vt=False,
|
||||
python_shell=False,
|
||||
)
|
||||
for pip_version, cmd_arg in cache_dir_arg_mapping.items():
|
||||
with patch('salt.modules.pip.version',
|
||||
MagicMock(return_value=pip_version)):
|
||||
# test `download_cache` kwarg
|
||||
pip.install(pkg, download_cache='/tmp/foo')
|
||||
mock.assert_called_with(
|
||||
['pip', 'install', cmd_arg, download_cache, pkg],
|
||||
saltenv='base',
|
||||
runas=None,
|
||||
use_vt=False,
|
||||
python_shell=False,
|
||||
)
|
||||
|
||||
# test `cache_dir` kwarg
|
||||
pip.install(pkg, cache_dir='/tmp/foo')
|
||||
mock.assert_called_with(
|
||||
['pip', 'install', cmd_arg, download_cache, pkg],
|
||||
saltenv='base',
|
||||
runas=None,
|
||||
use_vt=False,
|
||||
python_shell=False,
|
||||
)
|
||||
|
||||
def test_install_source_argument_in_resulting_command(self):
|
||||
pkg = 'pep8'
|
||||
|
Loading…
Reference in New Issue
Block a user