test_smoke.py 968 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import pytest
  2. from src.trader_mcp.server import app
  3. # Ensure src is a valid package import target in all runners.
  4. @pytest.fixture
  5. def client():
  6. try:
  7. from fastapi.testclient import TestClient
  8. except Exception as e: # pragma: no cover
  9. pytest.skip(f"TestClient not available: {e}")
  10. return TestClient(app)
  11. def test_root(client):
  12. r = client.get("/")
  13. assert r.status_code == 200
  14. assert r.json().get("status") == "ok"
  15. def test_health(client):
  16. r = client.get("/health")
  17. assert r.status_code == 200
  18. assert r.json().get("status") == "ok"
  19. def test_exec_list_accounts_returns_non_empty_json():
  20. # Prove we can fetch accounts from exec-mcp.
  21. from src.trader_mcp.exec_client import list_accounts
  22. accounts = list_accounts()
  23. assert isinstance(accounts, list)
  24. assert len(accounts) > 0
  25. # Spot-check expected fields.
  26. first = accounts[0]
  27. assert isinstance(first, dict)
  28. assert "id" in first