clan-cli: refactor HostGroup._run_local to work with RunOpts

This commit is contained in:
Qubasa
2024-11-28 16:05:51 +01:00
parent 466044e85f
commit 95cb239206
4 changed files with 78 additions and 123 deletions

View File

@@ -1,4 +1,4 @@
from clan_cli.cmd import Log
from clan_cli.cmd import Log, RunOpts
from clan_cli.ssh.host import Host
from clan_cli.ssh.host_group import HostGroup
@@ -31,7 +31,7 @@ def test_timeout() -> None:
def test_run_function() -> None:
def some_func(h: Host) -> bool:
par = h.run_local(["echo", "hello"], log=Log.STDERR)
par = h.run_local(["echo", "hello"], RunOpts(log=Log.STDERR))
return par.stdout == "hello\n"
res = hosts.run_function(some_func)
@@ -50,7 +50,7 @@ def test_run_exception() -> None:
def test_run_function_exception() -> None:
def some_func(h: Host) -> None:
h.run_local(["exit 1"], shell=True)
h.run_local(["exit 1"], RunOpts(shell=True))
try:
hosts.run_function(some_func)

View File

@@ -1,5 +1,5 @@
import pytest
from clan_cli.cmd import Log
from clan_cli.cmd import Log, RunOpts
from clan_cli.errors import ClanError, CmdOut
from clan_cli.ssh.host import Host
from clan_cli.ssh.host_group import HostGroup
@@ -73,7 +73,7 @@ def test_run_exception(host_group: HostGroup) -> None:
def test_run_function_exception(host_group: HostGroup) -> None:
def some_func(h: Host) -> CmdOut:
return h.run_local(["exit 1"], shell=True)
return h.run_local(["exit 1"], RunOpts(shell=True))
try:
host_group.run_function(some_func)