feat: API routes for models, chat, transcription, speech, and admin
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
62
kischdle/llmux/tests/test_routes.py
Normal file
62
kischdle/llmux/tests/test_routes.py
Normal file
@@ -0,0 +1,62 @@
|
||||
import pytest
|
||||
from fastapi import FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from llmux.config import ApiKey
|
||||
from llmux.auth import create_api_key_dependency
|
||||
from llmux.model_registry import ModelRegistry
|
||||
from llmux.vram_manager import VRAMManager
|
||||
from llmux.routes.models import create_models_router
|
||||
|
||||
API_KEY = "sk-test-key"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def registry():
|
||||
return ModelRegistry.from_config()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def vram_manager():
|
||||
return VRAMManager(total_vram_gb=16.0)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def app(registry, vram_manager):
|
||||
keys = [ApiKey(key=API_KEY, name="Test")]
|
||||
require_api_key = create_api_key_dependency(keys)
|
||||
app = FastAPI()
|
||||
app.include_router(create_models_router(registry, require_api_key))
|
||||
return app
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client(app):
|
||||
return TestClient(app)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def auth_headers():
|
||||
return {"Authorization": f"Bearer {API_KEY}"}
|
||||
|
||||
|
||||
def test_list_models_returns_16(client, auth_headers):
|
||||
resp = client.get("/v1/models", headers=auth_headers)
|
||||
assert resp.status_code == 200
|
||||
body = resp.json()
|
||||
assert body["object"] == "list"
|
||||
assert len(body["data"]) == 16
|
||||
|
||||
|
||||
def test_list_models_contains_expected_names(client, auth_headers):
|
||||
resp = client.get("/v1/models", headers=auth_headers)
|
||||
names = [m["id"] for m in resp.json()["data"]]
|
||||
assert "Qwen3.5-9B-FP8-Thinking" in names
|
||||
assert "GPT-OSS-20B-High" in names
|
||||
assert "cohere-transcribe" in names
|
||||
assert "Chatterbox-Multilingual" in names
|
||||
|
||||
|
||||
def test_list_models_requires_auth(client):
|
||||
resp = client.get("/v1/models")
|
||||
assert resp.status_code == 401
|
||||
Reference in New Issue
Block a user