fix python tests

This commit is contained in:
Jörg Thalheim 2023-12-03 12:54:33 +01:00 committed by mergify[bot]
parent 1e77cb3235
commit 25e19950f0

View File

@ -9,8 +9,8 @@ from nix_fast_build import async_main
from .sshd import Sshd
def cli(args: list[str]) -> None:
asyncio.run(async_main(args))
def cli(args: list[str]) -> int:
return asyncio.run(async_main(args))
def test_help() -> None:
@ -20,39 +20,36 @@ def test_help() -> None:
def test_build() -> None:
with pytest.raises(SystemExit) as e:
cli(["--option", "builders", ""])
assert e.value.code == 1
rc = cli(["--option", "builders", ""])
assert rc == 0
def test_eval_error() -> None:
with pytest.raises(SystemExit) as e:
cli(["--option", "builders", "", "--flake", ".#legacyPackages"])
assert e.value.code == 1
rc = cli(["--option", "builders", "", "--flake", ".#legacyPackages"])
assert rc == 1
def test_remote(sshd: Sshd) -> None:
login = pwd.getpwuid(os.getuid()).pw_name
with pytest.raises(SystemExit) as e:
cli(
[
"--option",
"builders",
"",
"--remote",
f"{login}@127.0.0.1",
"--remote-ssh-option",
"Port",
str(sshd.port),
"--remote-ssh-option",
"IdentityFile",
sshd.key,
"--remote-ssh-option",
"StrictHostKeyChecking",
"no",
"--remote-ssh-option",
"UserKnownHostsFile",
"/dev/null",
]
)
assert e.value.code == 0
rc = cli(
[
"--option",
"builders",
"",
"--remote",
f"{login}@127.0.0.1",
"--remote-ssh-option",
"Port",
str(sshd.port),
"--remote-ssh-option",
"IdentityFile",
sshd.key,
"--remote-ssh-option",
"StrictHostKeyChecking",
"no",
"--remote-ssh-option",
"UserKnownHostsFile",
"/dev/null",
]
)
assert rc == 0