docs: 为全部代码补充中文注释并加入 AGENTS 注释规范
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
"""用户应用 API 测试。
|
||||
|
||||
覆盖已发布应用的上传建任务、进度查询、产物下载、失败重试以及
|
||||
未发布/无版本工作流的拒绝逻辑。
|
||||
"""
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
@@ -9,6 +15,7 @@ WORKSPACE = Path(__file__).resolve().parent.parent.parent
|
||||
|
||||
|
||||
def _create_published_echo_workflow(client) -> str:
|
||||
"""注册 Echo 节点并创建一个已发布的单节点工作流。"""
|
||||
definition = {
|
||||
"name": "echo-flow",
|
||||
"version": 1,
|
||||
@@ -42,6 +49,7 @@ def _create_published_echo_workflow(client) -> str:
|
||||
|
||||
|
||||
def test_upload_run_progress_and_download() -> None:
|
||||
"""验证上传文件建任务、手动执行、查询产物与下载的完整流程。"""
|
||||
with TestClient(app) as client:
|
||||
workflow_id = _create_published_echo_workflow(client)
|
||||
apps = client.get("/api/apps")
|
||||
@@ -101,6 +109,7 @@ def test_upload_run_progress_and_download() -> None:
|
||||
|
||||
|
||||
def test_upload_rejects_unpublished_workflow() -> None:
|
||||
"""验证草稿或不存在的工作流不能被用户发起任务。"""
|
||||
with TestClient(app) as client:
|
||||
client.post(
|
||||
"/api/admin/workflows",
|
||||
@@ -129,6 +138,7 @@ def test_upload_rejects_unpublished_workflow() -> None:
|
||||
|
||||
|
||||
def test_upload_rejects_workflow_without_version() -> None:
|
||||
"""验证已发布但没有任何版本的工作流返回 422。"""
|
||||
with TestClient(app) as client:
|
||||
db = app.state.db
|
||||
db.upsert_workflow(
|
||||
@@ -142,6 +152,7 @@ def test_upload_rejects_workflow_without_version() -> None:
|
||||
|
||||
|
||||
def test_retry_failed_run_requeues_and_reruns() -> None:
|
||||
"""验证失败任务重试会清空旧产物并重新执行成功。"""
|
||||
with TestClient(app) as client:
|
||||
workflow_id = _create_published_echo_workflow(client)
|
||||
uploaded = client.post(
|
||||
@@ -183,6 +194,7 @@ def test_retry_failed_run_requeues_and_reruns() -> None:
|
||||
|
||||
|
||||
def test_retry_rejects_non_failed_and_missing_runs() -> None:
|
||||
"""验证只有 FAILED 状态且存在的任务才能重试。"""
|
||||
with TestClient(app) as client:
|
||||
workflow_id = _create_published_echo_workflow(client)
|
||||
uploaded = client.post(
|
||||
|
||||
Reference in New Issue
Block a user