Skip to content

Commit 6f4646f

Browse files
rootroot
authored andcommitted
test(api-server): add real provenance-safe unit checks
Replace brittle pytest collection on the manual smoke script with a real unit suite for alias resolution and model catalog exposure. Align CI and provenance verification so both workflows use the same non-Ollama Python checks.
1 parent 7e1d7d4 commit 6f4646f

4 files changed

Lines changed: 36 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,12 @@ jobs:
3636
- name: Lint (ruff)
3737
run: ruff check .
3838

39-
- name: Collect tests (no Ollama required)
40-
# test_api.py is an integration smoke test that requires a live Ollama server.
41-
# We collect-only to confirm the file is importable and has no syntax errors.
42-
# Set SKIP_INTEGRATION=1 as a convention for future test guards.
39+
- name: Run unit tests (no Ollama required)
4340
env:
4441
SKIP_INTEGRATION: "1"
4542
run: |
4643
pip install pytest
47-
python -m pytest test_api.py --collect-only -q || true
44+
python -m pytest test_server.py -q
4845
4946
chrome-bridge:
5047
name: chrome-bridge (Node.js)

.github/workflows/provenance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
pip install -r requirements.txt
7171
pip install pytest ruff
7272
ruff check .
73-
python -m pytest test_api.py --collect-only -q
73+
python -m pytest test_server.py -q
7474
7575
- name: Validate chrome-bridge
7676
working-directory: chrome-bridge

api-server/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Quick test — calls both models and prints responses."""
1+
"""Manual integration smoke script for a live local LLM API server."""
22
import httpx
33

44
BASE = "http://localhost:9000"

api-server/test_server.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from fastapi import HTTPException
2+
from fastapi.testclient import TestClient
3+
4+
from server import app, resolve
5+
6+
7+
def test_resolve_accepts_documented_aliases() -> None:
8+
assert resolve("nano") == "gemma3:1b"
9+
assert resolve("best") == "gemma3:12b"
10+
assert resolve("qwen") == "qwen3:8b"
11+
12+
13+
def test_resolve_rejects_unknown_models() -> None:
14+
try:
15+
resolve("missing-model")
16+
except HTTPException as exc:
17+
assert exc.status_code == 404
18+
assert "Unknown model" in str(exc.detail)
19+
else:
20+
raise AssertionError("resolve() should reject unknown models")
21+
22+
23+
def test_list_models_endpoint_exposes_catalog() -> None:
24+
client = TestClient(app)
25+
26+
response = client.get("/v1/models")
27+
28+
assert response.status_code == 200
29+
payload = response.json()
30+
ids = {model["id"] for model in payload["data"]}
31+
assert payload["object"] == "list"
32+
assert {"gemma3:12b", "qwen3:8b", "gemma3:1b", "phi3:mini"} <= ids

0 commit comments

Comments
 (0)