""" 冒烟测试:健康检查、API 前缀、projects 路由是否正常。 使用正确前缀 /api/v1/ 校验本次重构涉及的路由。 """ import pytest import sys import os sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) from fastapi.testclient import TestClient from src.main import app client = TestClient(app) API = "/api/v1" def unwrap_response_data(response): payload = response.json() return payload.get("data", payload) class TestSmokeHealth: """健康与存活""" def test_health(self): r = client.get("/health") assert r.status_code == 200 assert unwrap_response_data(r).get("status") == "healthy" def test_health_live(self): r = client.get("/health/live") assert r.status_code == 200 assert unwrap_response_data(r).get("status") == "alive" class TestSmokeProjects: """Projects 控制器(重构后)""" def test_list_projects(self): r = client.get(f"{API}/projects") assert r.status_code == 200 data = r.json() assert "data" in data or "items" in str(data) def test_get_nonexistent_project_404(self): r = client.get(f"{API}/projects/non-existent-id-12345") assert r.status_code == 404 class TestSmokeConfig: """Config 使用 /api/v1 前缀""" def test_get_system_config(self): r = client.get(f"{API}/config/system") assert r.status_code == 200 def test_get_models_config(self): r = client.get(f"{API}/config/models") assert r.status_code == 200 data = r.json() assert "data" in data or "models" in str(data)