Files
projectAIpopular/tests/test_gateway.py
T

45 lines
971 B
Python

"""???????? fastapi + httpx??"""
import pytest
pytest.importorskip("fastapi")
pytest.importorskip("httpx")
from fastapi.testclient import TestClient
from gateway.api import app
@pytest.fixture()
def client():
return TestClient(app)
def test_health(client):
resp = client.get("/health")
assert resp.status_code == 200
data = resp.json()
assert data["status"] == "ok"
assert "code" in data["domains"]
def test_chat(client):
resp = client.post("/chat", json={"query": "? Python ???????"})
assert resp.status_code == 200
data = resp.json()
assert data["response"]
assert data["domain"] == "code"
assert "route" in data
def test_chat_empty_query(client):
resp = client.post("/chat", json={"query": ""})
assert resp.status_code == 422
def test_metrics(client):
resp = client.get("/metrics")
assert resp.status_code == 200
data = resp.json()
assert "router" in data
assert "cache" in data