| 123456789101112131415161718192021222324252627282930313233343536373839 |
- import pytest
- from src.trader_mcp.server import app
- # Ensure src is a valid package import target in all runners.
- @pytest.fixture
- def client():
- try:
- from fastapi.testclient import TestClient
- except Exception as e: # pragma: no cover
- pytest.skip(f"TestClient not available: {e}")
- return TestClient(app)
- def test_root(client):
- r = client.get("/")
- assert r.status_code == 200
- assert r.json().get("status") == "ok"
- def test_health(client):
- r = client.get("/health")
- assert r.status_code == 200
- assert r.json().get("status") == "ok"
- def test_exec_list_accounts_returns_non_empty_json():
- # Prove we can fetch accounts from exec-mcp.
- from src.trader_mcp.exec_client import list_accounts
- accounts = list_accounts()
- assert isinstance(accounts, list)
- assert len(accounts) > 0
- # Spot-check expected fields.
- first = accounts[0]
- assert isinstance(first, dict)
- assert "id" in first
|