4b6817381b
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
84 lines
2.7 KiB
Python
84 lines
2.7 KiB
Python
"""Tests for Telegram gateway status copy."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from core.tool_framework.registered_tool import RegisteredTool
|
|
from gateway.status_messages import (
|
|
INITIAL_STATUSES,
|
|
_tool_label,
|
|
initial_status_message,
|
|
normalize_gateway_status,
|
|
status_from_response_label,
|
|
status_from_tool_start,
|
|
)
|
|
|
|
|
|
def _make_tool(name: str, description: str) -> RegisteredTool:
|
|
return RegisteredTool(
|
|
name=name,
|
|
description=description,
|
|
input_schema={"type": "object", "properties": {}, "required": []},
|
|
source="datadog",
|
|
run=lambda **_kwargs: {},
|
|
)
|
|
|
|
|
|
def _register(monkeypatch, tools: list[RegisteredTool]) -> None:
|
|
monkeypatch.setattr("tools.registry.get_registered_tools", lambda: tools)
|
|
_tool_label.cache_clear()
|
|
|
|
|
|
def test_initial_status_message_is_non_empty() -> None:
|
|
assert initial_status_message().strip()
|
|
assert initial_status_message() != "Working…"
|
|
|
|
|
|
def test_normalize_gateway_status_rejects_working_placeholder() -> None:
|
|
for banned in ("Working…", "Working...", "working", " Working ", ""):
|
|
assert normalize_gateway_status(banned) in INITIAL_STATUSES
|
|
assert normalize_gateway_status("keep this") == "keep this"
|
|
|
|
|
|
def test_response_label_maps_working_to_initial_status() -> None:
|
|
assert status_from_response_label("working") in INITIAL_STATUSES
|
|
assert status_from_response_label("") in INITIAL_STATUSES
|
|
|
|
|
|
def test_response_label_maps_assistant() -> None:
|
|
assert status_from_response_label("assistant") == "💬 Composing your reply…"
|
|
|
|
|
|
def test_response_label_falls_back_for_unknown_label() -> None:
|
|
assert status_from_response_label("gather") == "✨ gather…"
|
|
|
|
|
|
def test_tool_status_uses_registry_description(monkeypatch) -> None:
|
|
tool = _make_tool(
|
|
"query_datadog_monitors",
|
|
"Query Datadog monitors for alert configuration and state.",
|
|
)
|
|
_register(monkeypatch, [tool])
|
|
|
|
assert (
|
|
status_from_tool_start("query_datadog_monitors")
|
|
== "⏳ Query Datadog monitors for alert configuration and state…"
|
|
)
|
|
|
|
|
|
def test_tool_status_falls_back_to_humanized_name(monkeypatch) -> None:
|
|
_register(monkeypatch, [])
|
|
|
|
assert status_from_tool_start("list_open_pull_requests") == "⏳ list open pull requests…"
|
|
|
|
|
|
def test_tool_status_includes_first_input_hint(monkeypatch) -> None:
|
|
tool = _make_tool("slash_invoke", "Run a registered interactive-shell slash command.")
|
|
_register(monkeypatch, [tool])
|
|
|
|
status = status_from_tool_start(
|
|
"slash_invoke",
|
|
{"command": "/integrations", "args": ["verify", "telegram"]},
|
|
)
|
|
assert status.startswith("⏳ Run a registered interactive-shell slash command…")
|
|
assert "/integrations" in status
|