Add application setup and test infrastructure
Application Configuration: - FastAPI application factory pattern - CORS middleware for cross-origin support - Global exception handlers for consistent error responses - AppException handler for custom errors - RequestValidationError handler for Pydantic validation - General exception handler for unexpected errors - Lifespan management for startup/shutdown events - Router registration for all API endpoints - OpenAPI schema with interactive documentation Models Service: - Integration with ModelRegistry - List available models endpoint - Model capability discovery Test Infrastructure: - Pytest configuration with async support - Test client fixtures for sync and async testing - Comprehensive main application tests (14 tests): - App creation and metadata - Router registration verification - CORS middleware and functionality - Exception handler registration and behavior - Lifespan event handling - OpenAPI schema generation - Documentation accessibility - Validation error handling - Models API tests (2 tests) - Total: 95 tests, 78.95% coverage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+17
-10
@@ -9,23 +9,30 @@ from fastapi.testclient import TestClient
|
||||
def test_list_models(client: TestClient) -> None:
|
||||
"""Test listing available models."""
|
||||
response = client.get("/v1/models")
|
||||
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
|
||||
|
||||
# Verify response structure
|
||||
assert data["object"] == "list"
|
||||
assert "data" in data
|
||||
assert isinstance(data["data"], list)
|
||||
assert len(data["data"]) > 0
|
||||
|
||||
|
||||
# Should have both models from registry
|
||||
assert len(data["data"]) == 2
|
||||
|
||||
# Check for expected model IDs
|
||||
model_ids = [m["id"] for m in data["data"]]
|
||||
assert "lorem-tester" in model_ids
|
||||
assert "tatlock" in model_ids
|
||||
|
||||
# Verify model structure
|
||||
model = data["data"][0]
|
||||
assert model["object"] == "model"
|
||||
assert "id" in model
|
||||
assert model["id"] == "mistral-nemo:latest"
|
||||
assert "created" in model
|
||||
assert model["owned_by"] == "system"
|
||||
for model in data["data"]:
|
||||
assert model["object"] == "model"
|
||||
assert "id" in model
|
||||
assert "created" in model
|
||||
assert "owned_by" in model
|
||||
assert model["owned_by"] == "tatlock"
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
|
||||
Reference in New Issue
Block a user