mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
fixed failing tests
This commit is contained in:
parent
8a724997a7
commit
a81e0152ac
1 changed files with 16 additions and 3 deletions
|
@ -12,6 +12,8 @@ import salt.utils.path
|
|||
import salt.utils.platform
|
||||
import salt.utils.thin
|
||||
import salt.utils.yaml
|
||||
import salt.client.ssh.shell as shell
|
||||
import importlib
|
||||
from salt.client import ssh
|
||||
from tests.support.mock import MagicMock, call, patch
|
||||
|
||||
|
@ -27,6 +29,17 @@ def opts(master_opts):
|
|||
]
|
||||
return master_opts
|
||||
|
||||
@pytest.fixture()
|
||||
def mock_bin_paths():
|
||||
with patch("salt.utils.path.which") as mock_which:
|
||||
mock_which.side_effect = lambda x: {
|
||||
"ssh-keygen": "ssh-keygen",
|
||||
"ssh": "ssh",
|
||||
"scp": "scp",
|
||||
}.get(x, None)
|
||||
importlib.reload(shell)
|
||||
yield
|
||||
importlib.reload(shell)
|
||||
|
||||
@pytest.fixture
|
||||
def target():
|
||||
|
@ -45,7 +58,7 @@ def target():
|
|||
}
|
||||
|
||||
|
||||
def test_single_opts(opts, target):
|
||||
def test_single_opts(opts, target, mock_bin_paths):
|
||||
"""Sanity check for ssh.Single options"""
|
||||
|
||||
single = ssh.Single(
|
||||
|
@ -370,7 +383,7 @@ def test_shim_cmd_copy_fails(opts, target, caplog):
|
|||
mock_cmd.assert_not_called()
|
||||
|
||||
|
||||
def test_run_ssh_pre_flight_no_connect(opts, target, tmp_path, caplog):
|
||||
def test_run_ssh_pre_flight_no_connect(opts, target, tmp_path, caplog, mock_bin_paths):
|
||||
"""
|
||||
test Single.run_ssh_pre_flight when you
|
||||
cannot connect to the target
|
||||
|
@ -464,7 +477,7 @@ def test_run_ssh_pre_flight_permission_denied(opts, target, tmp_path):
|
|||
mock_exec_cmd.assert_not_called()
|
||||
|
||||
|
||||
def test_run_ssh_pre_flight_connect(opts, target, tmp_path, caplog):
|
||||
def test_run_ssh_pre_flight_connect(opts, target, tmp_path, caplog, mock_bin_paths):
|
||||
"""
|
||||
test Single.run_ssh_pre_flight when you
|
||||
can connect to the target
|
||||
|
|
Loading…
Add table
Reference in a new issue