Files
wehub-resource-sync 4b6817381b
Benchmark image — build + push to ECR (any adapter) / build + push (push) Waiting to run
CI / quality (ubuntu-latest) (push) Waiting to run
CI / test (tools-runtime) (push) Waiting to run
CI / test (e2e-general) (push) Waiting to run
CI / test (cli-runtime) (push) Waiting to run
CI / test (e2e-provider-and-openclaw) (push) Waiting to run
CI / test (integrations-and-misc) (push) Waiting to run
CI / coverage-report (push) Blocked by required conditions
CI / test-kubernetes (push) Waiting to run
CI / should-run-thorough (push) Waiting to run
CI / test-thorough (cloudwatch-demo) (push) Blocked by required conditions
CI / test-thorough (flink-ecs) (push) Blocked by required conditions
CI / test-thorough (upstream-lambda) (push) Blocked by required conditions
CI / test-thorough (prefect-ecs-fargate) (push) Blocked by required conditions
CodeQL / Analyze (python) (push) Waiting to run
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Blocked by required conditions
Release / publish-release (push) Blocked by required conditions
Release / publish-main-release (push) Blocked by required conditions
Release / prepare (push) Waiting to run
Release / verify (push) Blocked by required conditions
Release / build-python-dist (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Blocked by required conditions
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Waiting to run
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Waiting to run
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Waiting to run
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:10:45 +08:00

73 lines
2.2 KiB
Python

"""Unit tests for modular slash-command registry."""
from __future__ import annotations
import io
from rich.console import Console
from surfaces.interactive_shell.command_registry import SLASH_COMMANDS, dispatch_slash
from surfaces.interactive_shell.command_registry.integrations import (
_INTEGRATIONS_FIRST_ARGS,
_MCP_FIRST_ARGS,
)
from surfaces.interactive_shell.command_registry.investigation import (
_INVESTIGATE_FIRST_ARGS,
_TEMPLATE_FIRST_ARGS,
)
from surfaces.interactive_shell.command_registry.model.command import _MODEL_FIRST_ARGS
from surfaces.interactive_shell.command_registry.settings_cmds import (
_TRUST_FIRST_ARGS,
_VERBOSE_FIRST_ARGS,
)
from surfaces.interactive_shell.command_registry.tools_cmds import _TOOLS_FIRST_ARGS
from surfaces.interactive_shell.session import Session
def _capture() -> tuple[Console, io.StringIO]:
buf = io.StringIO()
return Console(file=buf, force_terminal=False, highlight=False), buf
def test_slash_registry_includes_modular_commands() -> None:
for name in (
"/help",
"/?",
"/exit",
"/model",
"/tools",
"/integrations",
"/investigate",
"/tasks",
"/watch",
"/watches",
"/unwatch",
"/health",
):
assert name in SLASH_COMMANDS
def test_dispatch_unknown_command_stays_in_repl() -> None:
session = Session()
console, buf = _capture()
assert dispatch_slash("/not-a-real-slash", session, console) is True
assert "Unknown command" in buf.getvalue()
def test_registry_first_arg_completion_hints_co_located_with_handlers() -> None:
"""Merged registry exposes the same first-arg tab tuples defined in each module."""
expected: dict[str, tuple[tuple[str, str], ...]] = {
"/model": _MODEL_FIRST_ARGS,
"/tools": _TOOLS_FIRST_ARGS,
"/integrations": _INTEGRATIONS_FIRST_ARGS,
"/mcp": _MCP_FIRST_ARGS,
"/investigate": _INVESTIGATE_FIRST_ARGS,
"/template": _TEMPLATE_FIRST_ARGS,
"/trust": _TRUST_FIRST_ARGS,
"/verbose": _VERBOSE_FIRST_ARGS,
}
for name, tup in expected.items():
assert SLASH_COMMANDS[name].first_arg_completions == tup
assert SLASH_COMMANDS["/help"].first_arg_completions == ()