Files
Cerbero-mcp/tests/integration/test_app_boot.py
T
Adriano 6faf21369d refactor(V2): get_historical & get_indicators are common-only on /mcp
Consolidate the cross-cutting data tools onto the unified interface and
remove their per-exchange duplicates.

- /mcp/tools/get_historical: single call, `exchange` now optional. Set →
  that venue's candles (native symbol); omitted → cross-exchange consensus
  (canonical symbol, median OHLC + div_pct). Folds in the former
  /mcp-cross consensus, whose router is deleted.
- /mcp/tools/get_indicators: new common tool computing sma/rsi/atr/macd/adx
  over the single-or-consensus series. Computation centralized in
  common/indicators.py::compute_indicators (was duplicated per exchange).
- Remove get_historical from /mcp-deribit and /mcp-hyperliquid; remove
  get_technical_indicators (deribit) and get_indicators (hyperliquid),
  including the now-dead client methods, Req schemas and tool wrappers.
  The client get_historical METHODS stay (used by the unified dispatch).

Tests: rewrite cross tests into test_unified (instruments, historical
single + consensus + failures, indicators single + consensus); drop the
old CrossClient test; tighten app-boot surface assertions (/mcp owns the
data tools; no /mcp-cross, no per-exchange historical/indicators).

Docs: API_REFERENCE / README / CLAUDE updated; smoke run_unified.sh now
covers consensus + indicators.

324 passed, ruff clean. Verified live against Deribit/Hyperliquid.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-29 10:51:21 +00:00

57 lines
2.1 KiB
Python

from __future__ import annotations
from fastapi.testclient import TestClient
def test_app_boots_and_health_responds(monkeypatch):
from tests.unit.test_settings import _minimal_env
for k, v in _minimal_env().items():
monkeypatch.setenv(k, v)
from cerbero_mcp.__main__ import _make_app
from cerbero_mcp.settings import Settings
app = _make_app(Settings())
c = TestClient(app)
r = c.get("/health")
assert r.status_code == 200
assert r.json()["status"] == "healthy"
r = c.get("/openapi.json")
assert r.status_code == 200
spec = r.json()
paths = spec["paths"].keys()
assert any(p.startswith("/mcp-deribit/") for p in paths)
assert any(p.startswith("/mcp-hyperliquid/") for p in paths)
assert any(p.startswith("/mcp-macro/") for p in paths)
assert any(p.startswith("/mcp-sentiment/") for p in paths)
# Unified common interface owns the cross-cutting data tools
assert "/mcp/tools/get_instruments" in paths
assert "/mcp/tools/get_historical" in paths
assert "/mcp/tools/get_indicators" in paths
# get_historical / get_indicators are common-only, not per-exchange
assert "/mcp-deribit/tools/get_historical" not in paths
assert "/mcp-deribit/tools/get_technical_indicators" not in paths
assert "/mcp-hyperliquid/tools/get_historical" not in paths
assert "/mcp-hyperliquid/tools/get_indicators" not in paths
# The standalone consensus router has been folded into /mcp
assert not any(p.startswith("/mcp-cross/") for p in paths)
# Bybit and Alpaca have been retired from the API surface
assert not any(p.startswith("/mcp-bybit/") for p in paths)
assert not any(p.startswith("/mcp-alpaca/") for p in paths)
def test_apidocs_available_after_boot(monkeypatch):
from tests.unit.test_settings import _minimal_env
for k, v in _minimal_env().items():
monkeypatch.setenv(k, v)
from cerbero_mcp.__main__ import _make_app
from cerbero_mcp.settings import Settings
c = TestClient(_make_app(Settings()))
r = c.get("/apidocs")
assert r.status_code == 200
assert "Cerbero MCP" in r.text