File size: 2,172 Bytes
0e76632 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | """Tests for /explore endpoints."""
import pytest
@pytest.mark.asyncio
async def test_root(client):
resp = await client.get("/")
assert resp.status_code == 200
# Root may return HTML (frontend) or JSON depending on mount order
try:
data = resp.json()
assert "MAC" in data.get("name", "")
except Exception:
# Frontend HTML served — still valid
assert "MAC" in resp.text or "html" in resp.text.lower()
@pytest.mark.asyncio
async def test_api_root(client):
resp = await client.get("/api/v1")
assert resp.status_code == 200
assert "auth" in resp.json()["endpoints"]
@pytest.mark.asyncio
async def test_explore_models(client):
resp = await client.get("/api/v1/explore/models")
assert resp.status_code == 200
data = resp.json()
assert "models" in data
assert "total" in data
@pytest.mark.asyncio
async def test_explore_models_search(client):
resp = await client.get("/api/v1/explore/models/search?tag=code")
assert resp.status_code == 200
data = resp.json()
assert isinstance(data["models"], list)
@pytest.mark.asyncio
async def test_explore_endpoints_list(client):
resp = await client.get("/api/v1/explore/endpoints")
assert resp.status_code == 200
data = resp.json()
assert data["total"] > 0
assert any("/auth/login" in e["path"] for e in data["endpoints"])
@pytest.mark.asyncio
async def test_explore_health(client):
resp = await client.get("/api/v1/explore/health")
assert resp.status_code == 200
data = resp.json()
assert data["status"] == "healthy"
assert data["version"] == "1.0.0"
@pytest.mark.asyncio
async def test_explore_model_detail(client):
resp = await client.get("/api/v1/explore/models/qwen2.5-coder:7b")
assert resp.status_code == 200
data = resp.json()
assert data["id"] == "qwen2.5-coder:7b"
assert "code" in data["capabilities"]
@pytest.mark.asyncio
async def test_explore_model_not_found(client):
resp = await client.get("/api/v1/explore/models/nonexistent-model")
assert resp.status_code == 404
|