test: 后端 pytest 测试基建 (Phase0) — 6 用例全绿 + 部署前备份SOP合规

This commit is contained in:
QihuAI Design committed 2026-07-18 23:29:55 +08:00
1 parent 9e9c506ba9
commit 13578ba4c2
7 files changed
+89

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
"""Phase 0 安全网 — 后端冒烟测试。
核心价值:证明整个后端(含 chat.py 等巨型模块)在测试环境下能无错误导入并挂载路由。
任何破坏 import 的脆弱补丁都会在此立刻变红,从而把"改了没生效 / 启动即崩"挡在部署前。
"""
def test_app_imports_and_has_routes():
from main import app
assert app is not None
# 真实路由数远超 0;若 chat.py 等模块 import 失败,本测试在 import 阶段即报错
assert len(app.routes) > 50
def test_openapi_schema_builds():
from main import app
schema = app.openapi()
assert "paths" in schema
assert len(schema["paths"]) > 0