docs: 为全部代码补充中文注释并加入 AGENTS 注释规范
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
"""应用级 API 冒烟测试。
|
||||
|
||||
使用 FastAPI TestClient 验证健康检查、静态页面、节点注册校验以及
|
||||
节点生命周期与手动调用等真实链路。
|
||||
"""
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
@@ -6,12 +12,14 @@ from fastapi.testclient import TestClient
|
||||
from app.main import app
|
||||
|
||||
WORKSPACE = Path(__file__).resolve().parent.parent.parent
|
||||
# 直接读取 Echo 节点 manifest 作为注册测试的真实数据。
|
||||
ECHO_MANIFEST = json.loads(
|
||||
(WORKSPACE / "wov-node-echo" / "node.manifest.json").read_text(encoding="utf-8")
|
||||
)
|
||||
|
||||
|
||||
def test_health() -> None:
|
||||
"""验证静态首页、OpenAPI 文档与健康探针均可访问。"""
|
||||
with TestClient(app) as client:
|
||||
root = client.get("/", follow_redirects=False)
|
||||
assert root.status_code == 200
|
||||
@@ -26,6 +34,7 @@ def test_health() -> None:
|
||||
|
||||
|
||||
def test_register_validation_errors() -> None:
|
||||
"""验证非法节点注册请求会被 Pydantic 或协议校验拒绝。"""
|
||||
with TestClient(app) as client:
|
||||
assert client.post("/api/admin/nodes", json={}).status_code == 422
|
||||
invalid = dict(ECHO_MANIFEST, id="")
|
||||
@@ -37,6 +46,7 @@ def test_register_validation_errors() -> None:
|
||||
|
||||
|
||||
def test_node_lifecycle_and_invoke() -> None:
|
||||
"""验证注册、查询、调用、停止与删除节点的完整生命周期。"""
|
||||
with TestClient(app) as client:
|
||||
registered = client.post("/api/admin/nodes", json=ECHO_MANIFEST)
|
||||
assert registered.status_code == 200
|
||||
|
||||
Reference in New Issue
Block a user