2013-07-08 17:26:34 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
'''
|
|
|
|
:codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)`
|
2013-09-16 16:24:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
tests.unit.modules.virtualenv_test
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2013-07-08 17:26:34 +00:00
|
|
|
'''
|
|
|
|
|
2013-07-09 22:07:17 +00:00
|
|
|
# Import python libraries
|
2014-11-21 19:05:13 +00:00
|
|
|
from __future__ import absolute_import
|
2014-02-07 00:01:40 +00:00
|
|
|
import sys
|
2013-07-08 17:26:34 +00:00
|
|
|
|
|
|
|
# Import Salt Testing libs
|
|
|
|
from salttesting import skipIf, TestCase
|
2013-07-12 23:13:37 +00:00
|
|
|
from salttesting.helpers import (
|
|
|
|
ensure_in_syspath,
|
|
|
|
TestsLoggingHandler,
|
|
|
|
ForceImportErrorOn
|
|
|
|
)
|
2013-08-26 09:40:45 +00:00
|
|
|
from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch
|
2013-07-08 17:26:34 +00:00
|
|
|
ensure_in_syspath('../../')
|
|
|
|
|
|
|
|
# Import salt libs
|
2013-08-20 22:44:05 +00:00
|
|
|
from salt.modules import virtualenv_mod
|
2013-07-09 22:07:17 +00:00
|
|
|
from salt.exceptions import CommandExecutionError
|
2013-07-08 17:26:34 +00:00
|
|
|
|
2013-08-20 22:44:05 +00:00
|
|
|
virtualenv_mod.__salt__ = {}
|
2014-01-11 19:58:46 +00:00
|
|
|
virtualenv_mod.__opts__['venv_bin'] = 'virtualenv'
|
2013-07-14 11:53:23 +00:00
|
|
|
base_virtualenv_mock = MagicMock()
|
|
|
|
base_virtualenv_mock.__version__ = '1.9.1'
|
|
|
|
|
2013-07-08 17:26:34 +00:00
|
|
|
|
2013-08-26 09:40:45 +00:00
|
|
|
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
2013-07-14 11:53:23 +00:00
|
|
|
@patch('salt.utils.which', lambda bin_name: bin_name)
|
|
|
|
@patch.dict('sys.modules', {'virtualenv': base_virtualenv_mock})
|
2013-07-08 17:26:34 +00:00
|
|
|
class VirtualenvTestCase(TestCase):
|
|
|
|
|
2013-07-12 11:48:10 +00:00
|
|
|
def test_issue_6029_deprecated_distribute(self):
|
2013-07-08 17:26:34 +00:00
|
|
|
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
|
|
|
|
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
|
|
|
virtualenv_mod._install_script = MagicMock(
|
2013-07-13 14:28:02 +00:00
|
|
|
return_value={
|
|
|
|
'retcode': 0,
|
|
|
|
'stdout': 'Installed script!',
|
|
|
|
'stderr': ''
|
|
|
|
}
|
|
|
|
)
|
2013-08-20 22:44:05 +00:00
|
|
|
virtualenv_mod.create(
|
2013-07-14 11:53:23 +00:00
|
|
|
'/tmp/foo', system_site_packages=True, distribute=True
|
|
|
|
)
|
|
|
|
mock.assert_called_once_with(
|
2014-12-09 06:28:28 +00:00
|
|
|
['virtualenv', '--distribute', '--system-site-packages', '/tmp/foo'],
|
|
|
|
runas=None,
|
|
|
|
python_shell=False
|
2013-07-14 11:53:23 +00:00
|
|
|
)
|
2013-07-08 19:03:41 +00:00
|
|
|
|
2013-07-12 11:48:10 +00:00
|
|
|
with TestsLoggingHandler() as handler:
|
2013-07-14 11:53:23 +00:00
|
|
|
# Let's fake a higher virtualenv version
|
2013-07-12 11:48:10 +00:00
|
|
|
virtualenv_mock = MagicMock()
|
|
|
|
virtualenv_mock.__version__ = '1.10rc1'
|
|
|
|
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
2013-07-12 11:48:10 +00:00
|
|
|
with patch.dict('sys.modules',
|
|
|
|
{'virtualenv': virtualenv_mock}):
|
2013-08-20 22:44:05 +00:00
|
|
|
virtualenv_mod.create(
|
2013-07-12 11:48:10 +00:00
|
|
|
'/tmp/foo', system_site_packages=True, distribute=True
|
|
|
|
)
|
|
|
|
mock.assert_called_once_with(
|
2014-12-09 06:28:28 +00:00
|
|
|
['virtualenv', '--system-site-packages', '/tmp/foo'],
|
|
|
|
runas=None,
|
|
|
|
python_shell=False
|
2013-07-12 11:48:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Are we logging the deprecation information?
|
|
|
|
self.assertIn(
|
|
|
|
'INFO:The virtualenv \'--distribute\' option has been '
|
|
|
|
'deprecated in virtualenv(>=1.10), as such, the '
|
|
|
|
'\'distribute\' option to `virtualenv.create()` has '
|
|
|
|
'also been deprecated and it\'s not necessary anymore.',
|
|
|
|
handler.messages
|
|
|
|
)
|
2013-07-08 19:03:41 +00:00
|
|
|
|
2013-07-08 19:14:16 +00:00
|
|
|
def test_issue_6030_deprecated_never_download(self):
|
2013-07-08 17:26:34 +00:00
|
|
|
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
|
2013-07-08 19:03:41 +00:00
|
|
|
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
|
|
|
virtualenv_mod.create(
|
2013-07-14 11:53:23 +00:00
|
|
|
'/tmp/foo', never_download=True
|
|
|
|
)
|
|
|
|
mock.assert_called_once_with(
|
2014-12-09 06:28:28 +00:00
|
|
|
['virtualenv', '--never-download', '/tmp/foo'],
|
|
|
|
runas=None,
|
|
|
|
python_shell=False
|
2013-07-14 11:53:23 +00:00
|
|
|
)
|
2013-07-08 19:03:41 +00:00
|
|
|
|
|
|
|
with TestsLoggingHandler() as handler:
|
|
|
|
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
|
2013-07-14 11:53:23 +00:00
|
|
|
# Let's fake a higher virtualenv version
|
2013-07-12 11:48:10 +00:00
|
|
|
virtualenv_mock = MagicMock()
|
|
|
|
virtualenv_mock.__version__ = '1.10rc1'
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
2013-07-12 11:48:10 +00:00
|
|
|
with patch.dict('sys.modules',
|
|
|
|
{'virtualenv': virtualenv_mock}):
|
2013-08-20 22:44:05 +00:00
|
|
|
virtualenv_mod.create(
|
2013-07-12 11:48:10 +00:00
|
|
|
'/tmp/foo', never_download=True
|
|
|
|
)
|
2014-12-09 06:28:28 +00:00
|
|
|
mock.assert_called_once_with(['virtualenv', '/tmp/foo'],
|
|
|
|
runas=None,
|
|
|
|
python_shell=False)
|
2013-07-12 11:48:10 +00:00
|
|
|
|
|
|
|
# Are we logging the deprecation information?
|
|
|
|
self.assertIn(
|
|
|
|
'INFO:The virtualenv \'--never-download\' option has been '
|
|
|
|
'deprecated in virtualenv(>=1.10), as such, the '
|
|
|
|
'\'never_download\' option to `virtualenv.create()` has '
|
|
|
|
'also been deprecated and it\'s not necessary anymore.',
|
|
|
|
handler.messages
|
2013-07-08 19:03:41 +00:00
|
|
|
)
|
2013-07-08 17:26:34 +00:00
|
|
|
|
2013-07-08 19:14:16 +00:00
|
|
|
def test_issue_6031_multiple_extra_search_dirs(self):
|
|
|
|
extra_search_dirs = [
|
|
|
|
'/tmp/bar-1',
|
|
|
|
'/tmp/bar-2',
|
|
|
|
'/tmp/bar-3'
|
|
|
|
]
|
|
|
|
|
|
|
|
# Passing extra_search_dirs as a list
|
|
|
|
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
|
|
|
virtualenv_mod.create(
|
2013-07-14 11:53:23 +00:00
|
|
|
'/tmp/foo', extra_search_dir=extra_search_dirs
|
|
|
|
)
|
|
|
|
mock.assert_called_once_with(
|
2014-12-09 06:28:28 +00:00
|
|
|
['virtualenv',
|
|
|
|
'--extra-search-dir=/tmp/bar-1',
|
|
|
|
'--extra-search-dir=/tmp/bar-2',
|
|
|
|
'--extra-search-dir=/tmp/bar-3',
|
|
|
|
'/tmp/foo'],
|
|
|
|
runas=None,
|
|
|
|
python_shell=False
|
2013-07-14 11:53:23 +00:00
|
|
|
)
|
2013-07-08 19:14:16 +00:00
|
|
|
|
|
|
|
# Passing extra_search_dirs as comma separated list
|
|
|
|
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
|
|
|
virtualenv_mod.create(
|
2013-07-14 11:53:23 +00:00
|
|
|
'/tmp/foo', extra_search_dir=','.join(extra_search_dirs)
|
|
|
|
)
|
|
|
|
mock.assert_called_once_with(
|
2014-12-09 06:28:28 +00:00
|
|
|
['virtualenv',
|
|
|
|
'--extra-search-dir=/tmp/bar-1',
|
|
|
|
'--extra-search-dir=/tmp/bar-2',
|
|
|
|
'--extra-search-dir=/tmp/bar-3',
|
|
|
|
'/tmp/foo'],
|
|
|
|
runas=None,
|
|
|
|
python_shell=False
|
2013-07-14 11:53:23 +00:00
|
|
|
)
|
2013-07-08 19:14:16 +00:00
|
|
|
|
2013-07-12 17:00:27 +00:00
|
|
|
def test_unapplicable_options(self):
|
|
|
|
# ----- Virtualenv using pyvenv options ----------------------------->
|
|
|
|
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
2013-07-12 17:00:27 +00:00
|
|
|
self.assertRaises(
|
|
|
|
CommandExecutionError,
|
2013-08-20 22:44:05 +00:00
|
|
|
virtualenv_mod.create,
|
2013-07-12 17:00:27 +00:00
|
|
|
'/tmp/foo',
|
|
|
|
venv_bin='virtualenv',
|
|
|
|
upgrade=True
|
|
|
|
)
|
|
|
|
|
|
|
|
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
2013-07-12 17:00:27 +00:00
|
|
|
self.assertRaises(
|
|
|
|
CommandExecutionError,
|
2013-08-20 22:44:05 +00:00
|
|
|
virtualenv_mod.create,
|
2013-07-12 17:00:27 +00:00
|
|
|
'/tmp/foo',
|
|
|
|
venv_bin='virtualenv',
|
|
|
|
symlinks=True
|
|
|
|
)
|
|
|
|
# <---- Virtualenv using pyvenv options ------------------------------
|
|
|
|
|
|
|
|
# ----- pyvenv using virtualenv options ----------------------------->
|
2013-08-20 22:44:05 +00:00
|
|
|
virtualenv_mod.__salt__ = {'cmd.which_bin': lambda _: 'pyvenv'}
|
2013-07-12 17:00:27 +00:00
|
|
|
|
|
|
|
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
|
|
|
|
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
2013-07-12 17:00:27 +00:00
|
|
|
self.assertRaises(
|
|
|
|
CommandExecutionError,
|
2013-08-20 22:44:05 +00:00
|
|
|
virtualenv_mod.create,
|
2013-07-12 17:00:27 +00:00
|
|
|
'/tmp/foo',
|
|
|
|
venv_bin='pyvenv',
|
|
|
|
python='python2.7'
|
|
|
|
)
|
|
|
|
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
2013-07-12 17:00:27 +00:00
|
|
|
self.assertRaises(
|
|
|
|
CommandExecutionError,
|
2013-08-20 22:44:05 +00:00
|
|
|
virtualenv_mod.create,
|
2013-07-12 17:00:27 +00:00
|
|
|
'/tmp/foo',
|
|
|
|
venv_bin='pyvenv',
|
|
|
|
prompt='PY Prompt'
|
|
|
|
)
|
|
|
|
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
2013-07-12 17:00:27 +00:00
|
|
|
self.assertRaises(
|
|
|
|
CommandExecutionError,
|
2013-08-20 22:44:05 +00:00
|
|
|
virtualenv_mod.create,
|
2013-07-12 17:00:27 +00:00
|
|
|
'/tmp/foo',
|
|
|
|
venv_bin='pyvenv',
|
|
|
|
never_download=True
|
|
|
|
)
|
|
|
|
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
2013-07-12 17:00:27 +00:00
|
|
|
self.assertRaises(
|
|
|
|
CommandExecutionError,
|
2013-08-20 22:44:05 +00:00
|
|
|
virtualenv_mod.create,
|
2013-07-12 17:00:27 +00:00
|
|
|
'/tmp/foo',
|
|
|
|
venv_bin='pyvenv',
|
|
|
|
extra_search_dir='/tmp/bar'
|
|
|
|
)
|
|
|
|
# <---- pyvenv using virtualenv options ------------------------------
|
|
|
|
|
2013-07-12 18:33:21 +00:00
|
|
|
def test_get_virtualenv_version_from_shell(self):
|
2013-07-12 23:13:37 +00:00
|
|
|
with ForceImportErrorOn('virtualenv'):
|
2013-07-12 18:33:21 +00:00
|
|
|
|
|
|
|
# ----- virtualenv binary not available ------------------------->
|
|
|
|
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
2013-07-12 18:33:21 +00:00
|
|
|
self.assertRaises(
|
|
|
|
CommandExecutionError,
|
2013-08-20 22:44:05 +00:00
|
|
|
virtualenv_mod.create,
|
2013-07-12 18:33:21 +00:00
|
|
|
'/tmp/foo',
|
|
|
|
)
|
|
|
|
# <---- virtualenv binary not available --------------------------
|
|
|
|
|
|
|
|
# ----- virtualenv binary present but > 0 exit code ------------->
|
|
|
|
mock = MagicMock(side_effect=[
|
|
|
|
{'retcode': 1, 'stdout': '', 'stderr': 'This is an error'},
|
|
|
|
{'retcode': 0, 'stdout': ''}
|
|
|
|
])
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
2013-07-12 18:33:21 +00:00
|
|
|
self.assertRaises(
|
|
|
|
CommandExecutionError,
|
2013-08-20 22:44:05 +00:00
|
|
|
virtualenv_mod.create,
|
2013-07-12 18:33:21 +00:00
|
|
|
'/tmp/foo',
|
|
|
|
venv_bin='virtualenv',
|
|
|
|
)
|
|
|
|
# <---- virtualenv binary present but > 0 exit code --------------
|
|
|
|
|
2014-04-30 19:06:27 +00:00
|
|
|
# ----- virtualenv binary returns 1.9.1 as its version --------->
|
2013-07-12 18:33:21 +00:00
|
|
|
mock = MagicMock(side_effect=[
|
|
|
|
{'retcode': 0, 'stdout': '1.9.1'},
|
|
|
|
{'retcode': 0, 'stdout': ''}
|
|
|
|
])
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
|
|
|
virtualenv_mod.create(
|
2013-07-12 18:33:21 +00:00
|
|
|
'/tmp/foo', never_download=True
|
|
|
|
)
|
|
|
|
mock.assert_called_with(
|
2014-12-09 06:28:28 +00:00
|
|
|
['virtualenv', '--never-download', '/tmp/foo'],
|
|
|
|
runas=None,
|
|
|
|
python_shell=False
|
2013-07-12 18:33:21 +00:00
|
|
|
)
|
2014-04-30 19:06:27 +00:00
|
|
|
# <---- virtualenv binary returns 1.9.1 as its version ----------
|
2013-07-12 18:33:21 +00:00
|
|
|
|
2014-04-30 19:06:27 +00:00
|
|
|
# ----- virtualenv binary returns 1.10rc1 as its version ------->
|
2013-07-12 18:33:21 +00:00
|
|
|
mock = MagicMock(side_effect=[
|
|
|
|
{'retcode': 0, 'stdout': '1.10rc1'},
|
|
|
|
{'retcode': 0, 'stdout': ''}
|
|
|
|
])
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
|
|
|
virtualenv_mod.create(
|
2013-07-12 18:33:21 +00:00
|
|
|
'/tmp/foo', never_download=True
|
|
|
|
)
|
|
|
|
mock.assert_called_with(
|
2014-12-09 06:28:28 +00:00
|
|
|
['virtualenv', '/tmp/foo'],
|
|
|
|
runas=None,
|
|
|
|
python_shell=False
|
2013-07-12 18:33:21 +00:00
|
|
|
)
|
2014-04-30 19:06:27 +00:00
|
|
|
# <---- virtualenv binary returns 1.10rc1 as its version --------
|
2013-07-12 18:33:21 +00:00
|
|
|
|
2013-07-14 11:53:23 +00:00
|
|
|
def test_python_argument(self):
|
|
|
|
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
|
2014-02-07 00:01:40 +00:00
|
|
|
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
|
|
|
virtualenv_mod.create(
|
2014-02-07 00:01:40 +00:00
|
|
|
'/tmp/foo', python=sys.executable,
|
2013-07-14 11:53:23 +00:00
|
|
|
)
|
|
|
|
mock.assert_called_once_with(
|
2014-12-09 06:28:28 +00:00
|
|
|
['virtualenv', '--python={0}'.format(sys.executable), '/tmp/foo'],
|
|
|
|
runas=None,
|
|
|
|
python_shell=False
|
2013-07-14 11:53:23 +00:00
|
|
|
)
|
|
|
|
|
2013-07-14 12:04:11 +00:00
|
|
|
def test_prompt_argument(self):
|
|
|
|
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
|
|
|
virtualenv_mod.create('/tmp/foo', prompt='PY Prompt')
|
2013-07-14 12:04:11 +00:00
|
|
|
mock.assert_called_once_with(
|
2014-12-09 06:28:28 +00:00
|
|
|
['virtualenv', '--prompt=\'PY Prompt\'', '/tmp/foo'],
|
|
|
|
runas=None,
|
|
|
|
python_shell=False
|
2013-07-14 12:04:11 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Now with some quotes on the mix
|
|
|
|
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
|
|
|
virtualenv_mod.create('/tmp/foo', prompt='\'PY\' Prompt')
|
2013-07-14 12:04:11 +00:00
|
|
|
mock.assert_called_once_with(
|
2014-12-09 06:28:28 +00:00
|
|
|
['virtualenv', '--prompt="\'PY\' Prompt"', '/tmp/foo'],
|
|
|
|
runas=None,
|
|
|
|
python_shell=False
|
2013-07-14 12:04:11 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
|
|
|
virtualenv_mod.create('/tmp/foo', prompt='"PY" Prompt')
|
2013-07-14 12:04:11 +00:00
|
|
|
mock.assert_called_once_with(
|
2014-12-09 06:28:28 +00:00
|
|
|
['virtualenv', '--prompt=\'"PY" Prompt\'', '/tmp/foo'],
|
|
|
|
runas=None,
|
|
|
|
python_shell=False
|
2013-07-14 12:04:11 +00:00
|
|
|
)
|
|
|
|
|
2013-07-14 12:23:18 +00:00
|
|
|
def test_clear_argument(self):
|
|
|
|
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
|
|
|
virtualenv_mod.create('/tmp/foo', clear=True)
|
2013-07-14 12:23:18 +00:00
|
|
|
mock.assert_called_once_with(
|
2014-12-09 06:28:28 +00:00
|
|
|
['virtualenv', '--clear', '/tmp/foo'],
|
|
|
|
runas=None,
|
|
|
|
python_shell=False
|
2013-07-14 12:23:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_upgrade_argument(self):
|
|
|
|
# We test for pyvenv only because with virtualenv this is un
|
|
|
|
# unsupported option.
|
|
|
|
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
|
|
|
virtualenv_mod.create('/tmp/foo', venv_bin='pyvenv', upgrade=True)
|
2013-07-14 12:23:18 +00:00
|
|
|
mock.assert_called_once_with(
|
2014-12-09 06:28:28 +00:00
|
|
|
['pyvenv', '--upgrade', '/tmp/foo'],
|
|
|
|
runas=None,
|
|
|
|
python_shell=False
|
2013-07-14 12:23:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_symlinks_argument(self):
|
|
|
|
# We test for pyvenv only because with virtualenv this is un
|
|
|
|
# unsupported option.
|
|
|
|
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
|
2013-08-20 22:44:05 +00:00
|
|
|
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
|
|
|
|
virtualenv_mod.create('/tmp/foo', venv_bin='pyvenv', symlinks=True)
|
2013-07-14 12:23:18 +00:00
|
|
|
mock.assert_called_once_with(
|
2014-12-09 06:28:28 +00:00
|
|
|
['pyvenv', '--symlinks', '/tmp/foo'],
|
|
|
|
runas=None,
|
|
|
|
python_shell=False
|
2013-07-14 12:23:18 +00:00
|
|
|
)
|
|
|
|
|
2013-07-08 18:31:38 +00:00
|
|
|
|
2013-07-08 17:26:34 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
from integration import run_tests
|
|
|
|
run_tests(VirtualenvTestCase, needs_daemon=False)
|