GRM-107: refactor: use devx Makefile aliases, bump devx>=0.23.0
Post-merge / detect-type (push) Successful in 1m3s
Post-merge / release (push) Successful in 1m8s
Post-merge / validate-commit-msg (push) Successful in 1m9s
Post-merge / vikunja (push) Successful in 1m13s
Post-merge / badges (push) Successful in 1m19s
Post-merge / sync-wiki (push) Successful in 1m44s
Post-merge / publish (push) Successful in 1m3s
Post-merge / configure-repo (push) Successful in 1m18s
Post-merge / detect-type (push) Successful in 1m3s
Post-merge / release (push) Successful in 1m8s
Post-merge / validate-commit-msg (push) Successful in 1m9s
Post-merge / vikunja (push) Successful in 1m13s
Post-merge / badges (push) Successful in 1m19s
Post-merge / sync-wiki (push) Successful in 1m44s
Post-merge / publish (push) Successful in 1m3s
Post-merge / configure-repo (push) Successful in 1m18s
This commit was merged in pull request #174.
This commit is contained in:
@@ -212,17 +212,14 @@ class TestAnsibleExecutorAdHoc:
|
||||
result_mock.stderr = ""
|
||||
|
||||
with patch("subprocess.run", return_value=result_mock) as mock_run:
|
||||
with patch("sys.stdin.isatty", return_value=True):
|
||||
result = executor.run_ad_hoc(
|
||||
"10.0.0.1", "ubuntu", None, "shell", "cmd", become=True, ask_become_pass=True
|
||||
)
|
||||
result = executor.run_ad_hoc("10.0.0.1", "ubuntu", None, "shell", "cmd", become=True, ask_become_pass=True)
|
||||
|
||||
assert result == "ok"
|
||||
cmd = mock_run.call_args.args[0]
|
||||
assert "--become" in cmd
|
||||
assert "--ask-become-pass" in cmd
|
||||
|
||||
def test_run_ad_hoc_ask_become_pass_no_tty(self, tmp_path: Path) -> None:
|
||||
def test_run_ad_hoc_with_become_pass(self, tmp_path: Path) -> None:
|
||||
executor = AnsibleExecutor(log_dir=tmp_path)
|
||||
result_mock = MagicMock()
|
||||
result_mock.stdout = "ok\n"
|
||||
@@ -230,14 +227,37 @@ class TestAnsibleExecutorAdHoc:
|
||||
result_mock.stderr = ""
|
||||
|
||||
with patch("subprocess.run", return_value=result_mock) as mock_run:
|
||||
with patch("sys.stdin.isatty", return_value=False):
|
||||
with patch("os.unlink"):
|
||||
result = executor.run_ad_hoc(
|
||||
"10.0.0.1", "ubuntu", None, "shell", "cmd", become=True, ask_become_pass=True
|
||||
"10.0.0.1",
|
||||
"ubuntu",
|
||||
None,
|
||||
"shell",
|
||||
"cmd",
|
||||
become=True,
|
||||
ask_become_pass=True,
|
||||
become_pass="secret",
|
||||
)
|
||||
|
||||
assert result == "ok"
|
||||
cmd = mock_run.call_args.args[0]
|
||||
assert "--become" in cmd
|
||||
assert "--become-password-file" in cmd
|
||||
assert "--ask-become-pass" not in cmd
|
||||
|
||||
def test_run_ad_hoc_ask_become_pass_no_become(self, tmp_path: Path) -> None:
|
||||
executor = AnsibleExecutor(log_dir=tmp_path)
|
||||
result_mock = MagicMock()
|
||||
result_mock.stdout = "ok\n"
|
||||
result_mock.returncode = 0
|
||||
result_mock.stderr = ""
|
||||
|
||||
with patch("subprocess.run", return_value=result_mock) as mock_run:
|
||||
result = executor.run_ad_hoc("10.0.0.1", "ubuntu", None, "shell", "cmd", become=False, ask_become_pass=True)
|
||||
|
||||
assert result == "ok"
|
||||
cmd = mock_run.call_args.args[0]
|
||||
assert "--become" not in cmd
|
||||
assert "--ask-become-pass" not in cmd
|
||||
|
||||
def test_run_ad_hoc_check_false(self, tmp_path: Path) -> None:
|
||||
|
||||
Reference in New Issue
Block a user