Refactor command handling

This now supports usage/help texts
This commit is contained in:
2025-05-18 17:56:53 +02:00
parent 26ef9b45d4
commit dcf0b4274c
15 changed files with 337 additions and 431 deletions

View File

@ -1,8 +1,11 @@
"""Test for the ping command."""
import allure
import pytest
from .types import ClientRegistry, CommandRunner
@allure.title("Test running the ping command")
@pytest.mark.asyncio
async def test_ping_command(
ssh_command_runner: CommandRunner, client_registry: ClientRegistry
@ -16,3 +19,21 @@ async def test_ping_command(
assert result.stdout is not None
assert isinstance(result.stdout, str)
assert result.stdout.rstrip() == "PONG"
@allure.title("Test ping help")
@pytest.mark.asyncio
async def test_ping_cmd_help(ssh_command_runner: CommandRunner, client_registry: ClientRegistry) -> None:
"""Test running ping --help."""
await client_registry["add_client"]("test-client", ["mysecret"])
result = await ssh_command_runner("test-client", "ping --help")
assert result.exit_status == 0
print(result.stdout)
assert isinstance(result.stdout, str)
lines = result.stdout.splitlines()
assert lines[0] == "ping"
assert len(lines) > 4