feat(schedule): 新增平台任务参数契约与动态选项支持

This commit is contained in:
hugo committed 2026-07-09 13:19:36 +08:00
1 parent 2ce1aca023
commit 8b5b0b49bf
76 files changed
+7103 -1203

No files matched your search

+45
View File
@@ -156,3 +156,48 @@ def test_chat_turn_rejects_shipping_action_for_non_shipping_agent(app, client):
assert res.status_code == 200
events = _parse_sse_events(res.get_data(as_text=True))
assert any(item.get("event") == "run.failed" for item in events)
def test_chat_turn_multipart_upload_reads_agent_id_from_form(app, client, monkeypatch, tmp_path):
"""multipart 上传发货通知时,agent_id 应从 form 字段解析,而非 JSON body。"""
from io import BytesIO
user = _create_user()
agent = _create_shipping_agent()
app.config["SHIPPING_NOTICE_STORAGE_ROOT"] = str(tmp_path)
monkeypatch.setattr(
"app.services.shipping_notice.batch_from_notices.create_shipping_batch_from_notice_items",
lambda **kwargs: {
"status": "ok",
"batch_no": "SB-MULTIPART-001",
"data": {
"tasks": [{"task_id": "SN-MULTIPART-001"}],
"focus_task": {"task_no": "SN-MULTIPART-001"},
},
},
)
res = client.post(
"/api/chat/turns/stream",
headers={"X-Username": user.username, "X-Role": user.role},
data={
"agent_id": str(agent.id),
"input": json.dumps(
{
"type": "upload_followup",
"display_text": "上传发货通知:notice.txt",
"action_type": "shipping.create_batch_from_notices",
"payload": {},
},
ensure_ascii=False,
),
"files": (BytesIO("客户:ACME\nA001 x 10".encode("utf-8")), "notice.txt"),
},
content_type="multipart/form-data",
)
assert res.status_code == 200
events = _parse_sse_events(res.get_data(as_text=True))
event_names = [item.get("event") for item in events]
assert "run.started" in event_names
assert "run.completed" in event_names
assert "run.failed" not in event_names