chore: import upstream snapshot with attribution
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
"""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 == ()
|
||||
Reference in New Issue
Block a user