Files
pixel/backend/tests/test_smoke.py
张鹏 f9f4560459 Initial commit: Pixel AI comic/video creation platform
- FastAPI backend with SQLModel, Alembic migrations, AgentScope agents
- Next.js 15 frontend with React 19, Tailwind, Zustand, React Flow
- Multi-provider AI system (DashScope, Kling, MiniMax, Volcengine, OpenAI, etc.)
- All HTTP clients migrated from sync requests to async httpx
- Admin-managed API keys via environment variables
- SSRF vulnerability fixed in ensure_url()
2026-04-29 01:20:12 +08:00

63 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
冒烟测试健康检查、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)