oclaw/tests/test_run_command_aliases.py
oliver e03c90fb35 Add one-shot UME alarm Excel delivery for WhatsApp ops.
Collapse query+xlsx+deliverable into ume_alarm_xlsx_report, allow write_xlsx(deliverable=true), and accept run_command aliases to cut multi-tool loops.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-10 22:36:14 +08:00

26 lines
1,004 B
Python

from __future__ import annotations
from runtime.tools.public.run_command_tool import run_command_tool
from runtime.tools.tool_validation import filter_arguments_to_schema, validate_tool_arguments
def test_run_command_accepts_cmd_alias(monkeypatch) -> None:
calls: list[dict] = []
class _Adapter:
def run_command(self, *, command: str, cwd=None, timeout: int = 300):
calls.append({"command": command, "cwd": cwd, "timeout": timeout})
return {"ok": True, "stdout": "hi", "stderr": "", "exit_code": 0}
monkeypatch.setattr(
"runtime.tools.public.run_command_tool.get_local_adapter",
lambda: _Adapter(),
)
spec = run_command_tool()
args = {"cmd": "echo hi", "timeout": 10}
filtered = filter_arguments_to_schema(spec.parameters, args)
ok, err = validate_tool_arguments(spec.parameters, filtered)
assert ok, err
out = spec.handler(filtered)
assert out.get("ok") is True
assert calls[0]["command"] == "echo hi"