mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
add tests
This commit is contained in:
parent
6b9c3faf11
commit
d2688ae80e
2 changed files with 44 additions and 7 deletions
|
@ -148,10 +148,9 @@ def _check_bundled():
|
|||
"""
|
||||
Gather run-time information to indicate if we are running from source or bundled.
|
||||
"""
|
||||
frozen = False
|
||||
if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
|
||||
frozen = True
|
||||
return frozen
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def _get_pip_bin(bin_env):
|
||||
|
|
|
@ -38,10 +38,48 @@ class PipTestCase(TestCase, LoaderModuleMockMixin):
|
|||
ret = pip._pip_bin_env(None, None)
|
||||
self.assertIsNone(ret)
|
||||
|
||||
def test__pip_bin_bundled_app(self):
|
||||
sys_info = hasattr(sys, "sys._MEIPASS")
|
||||
ret = pip._check_bundled()
|
||||
self.assertEqual(ret, sys_info)
|
||||
def test_install_frozen_app(self):
|
||||
pkg = "pep8"
|
||||
mock = MagicMock(return_value={"retcode": 0, "stdout": ""})
|
||||
with patch("sys.frozen", True, create=True):
|
||||
with patch("sys._MEIPASS", True, create=True):
|
||||
with patch.dict(pip.__salt__, {"cmd.run_all": mock}):
|
||||
pip.install(pkg)
|
||||
expected = [
|
||||
sys.executable,
|
||||
"pip",
|
||||
"install",
|
||||
pkg,
|
||||
]
|
||||
mock.assert_called_with(
|
||||
expected,
|
||||
python_shell=False,
|
||||
saltenv="base",
|
||||
use_vt=False,
|
||||
runas=None,
|
||||
)
|
||||
|
||||
def test_install_source_app(self):
|
||||
pkg = "pep8"
|
||||
mock = MagicMock(return_value={"retcode": 0, "stdout": ""})
|
||||
with patch("sys.frozen", False, create=True):
|
||||
with patch("sys._MEIPASS", False, create=True):
|
||||
with patch.dict(pip.__salt__, {"cmd.run_all": mock}):
|
||||
pip.install(pkg)
|
||||
expected = [
|
||||
sys.executable,
|
||||
"-m",
|
||||
"pip",
|
||||
"install",
|
||||
pkg,
|
||||
]
|
||||
mock.assert_called_with(
|
||||
expected,
|
||||
python_shell=False,
|
||||
saltenv="base",
|
||||
use_vt=False,
|
||||
runas=None,
|
||||
)
|
||||
|
||||
def test_fix4361(self):
|
||||
mock = MagicMock(return_value={"retcode": 0, "stdout": ""})
|
||||
|
|
Loading…
Add table
Reference in a new issue