"""End-to-end test of SSH transport with hermit-dev."""
import asyncio
from sympathy_mcp.transport import vm_exec, vm_file_write, vm_file_read
async def test():
# Test 1: vm_exec
print("=== Test 1: vm_exec ===")
result = await vm_exec("hermit-dev", "echo hello")
print(f"stdout: {result.stdout!r}")
print(f"stderr: {result.stderr!r}")
print(f"exit_code: {result.exit_code}")
assert result.stdout.strip() == "hello", f"Expected hello, got {result.stdout!r}"
assert result.exit_code == 0
print("PASS\n")
# Test 2: vm_file_write
print("=== Test 2: vm_file_write ===")
result = await vm_file_write("hermit-dev", "/tmp/test.txt", "hello world")
print(f"exit_code: {result.exit_code}")
assert result.exit_code == 0
print("PASS\n")
# Test 3: vm_file_read
print("=== Test 3: vm_file_read ===")
content = await vm_file_read("hermit-dev", "/tmp/test.txt")
print(f"content: {content!r}")
assert content == "hello world", f'Expected "hello world", got {content!r}'
print("PASS\n")
# Test 4: vm_exec with workdir
print("=== Test 4: vm_exec with workdir ===")
result = await vm_exec("hermit-dev", "pwd", workdir="/tmp")
print(f"stdout: {result.stdout!r}")
assert result.stdout.strip() == "/tmp"
print("PASS\n")
# Test 5: vm_exec with shell features (pipes)
print("=== Test 5: vm_exec with shell features ===")
result = await vm_exec("hermit-dev", "echo one two three | wc -w")
print(f"stdout: {result.stdout!r}")
assert result.stdout.strip() == "3"
assert result.exit_code == 0
print("PASS\n")
print("All 5 tests passed!")
if __name__ == "__main__":
asyncio.run(test())