edge-latency-aware-cross-ve.../tests/test_api.py

25 lines
758 B
Python

from fastapi.testclient import TestClient
try:
# Prefer the alias surface to accommodate environments where src is not on PYTHONPATH
from elac_plan.api.app import app
except Exception:
from edge_latency_aware_cross_venue_execution.api.app import app
def test_create_problem_and_status():
client = TestClient(app)
payload = {
"id": "arb-1",
"asset": "AAPL",
"venue": "VENUE1",
"objective": "min_spread",
"parameters": {"max_latency_ms": 5},
}
resp = client.post("/problems", json=payload)
assert resp.status_code == 200
data = resp.json()
assert data["contract_id"] == "arb-1"
# Check status endpoint
st = client.get("/status").json()
assert "problems_count" in st