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

74 lines
2.2 KiB
Python

"""Tests for the /gateway slash command."""
from __future__ import annotations
from unittest.mock import MagicMock
import pytest
from rich.console import Console
from surfaces.interactive_shell.command_registry.gateway_cmds import _cmd_gateway
_MODULE = "surfaces.interactive_shell.command_registry.gateway_cmds"
@pytest.fixture
def console() -> Console:
return Console(record=True, force_terminal=False, width=200)
def _output(console: Console) -> str:
return console.export_text()
def test_status_shows_running_daemon_and_components(
monkeypatch: pytest.MonkeyPatch, console: Console
) -> None:
monkeypatch.setattr(f"{_MODULE}.gateway_daemon_pid", lambda: 4242)
monkeypatch.setattr(
f"{_MODULE}.read_component_status",
lambda: {"web": "serving :8000", "telegram": "polling for messages"},
)
assert _cmd_gateway(MagicMock(), console, ["status"]) is True
out = _output(console)
assert "running (pid 4242)" in out
assert "web: serving :8000" in out
assert "telegram: polling for messages" in out
def test_bare_gateway_defaults_to_status(monkeypatch: pytest.MonkeyPatch, console: Console) -> None:
monkeypatch.setattr(f"{_MODULE}.gateway_daemon_pid", lambda: None)
monkeypatch.setattr(f"{_MODULE}.read_component_status", dict)
assert _cmd_gateway(MagicMock(), console, []) is True
assert "stopped" in _output(console)
def test_start_reports_outcome_and_log_path(
monkeypatch: pytest.MonkeyPatch, console: Console
) -> None:
monkeypatch.setattr(
f"{_MODULE}.start_gateway_daemon",
lambda: (True, "OpenSRE gateway started (pid 7)."),
)
assert _cmd_gateway(MagicMock(), console, ["start"]) is True
out = _output(console)
assert "started (pid 7)" in out
assert "gateway.log" in out
def test_logs_prints_tail(monkeypatch: pytest.MonkeyPatch, console: Console) -> None:
monkeypatch.setattr(f"{_MODULE}.read_gateway_log_tail", lambda lines: f"tail of {lines}")
assert _cmd_gateway(MagicMock(), console, ["logs", "7"]) is True
assert "tail of 7" in _output(console)
def test_unknown_subcommand_prints_usage(console: Console) -> None:
assert _cmd_gateway(MagicMock(), console, ["restart"]) is True
assert "usage:" in _output(console)