feat: 收口通知原因语义与留痕校验
This commit is contained in:
@@ -513,6 +513,49 @@ def test_feishu_notification_report_builds_notification_payload_with_receipt_and
|
||||
assert result.notification_payload["receipt"]["message_id"] == "msg-3"
|
||||
|
||||
|
||||
def test_notification_payload_normalizes_unsupported_notify_reason():
|
||||
scenario = {
|
||||
"id": "document_review",
|
||||
"name": "注册审核智能体",
|
||||
"agent": {
|
||||
"role": "注册审核助手",
|
||||
"goal": "输出通知结果",
|
||||
"instructions": ["输出结构化通知结果"],
|
||||
},
|
||||
"rag": {"enabled": False},
|
||||
"tools": [],
|
||||
"output": {"type": "feishu_notification_report"},
|
||||
}
|
||||
provider_response = """
|
||||
{
|
||||
"batch_id": "SUB-20260604-004",
|
||||
"conversation_id": "conv-004",
|
||||
"notify_reason": "custom_reason",
|
||||
"mentioned_users": ["ou_demo_1"],
|
||||
"message_status": "sent"
|
||||
}
|
||||
"""
|
||||
|
||||
class FakeProvider:
|
||||
def generate(self, messages, response_format=None):
|
||||
from agent_core.llm_provider import LLMResponse
|
||||
|
||||
return LLMResponse(content=provider_response, model_name="demo-model", success=True)
|
||||
|
||||
result = run_agent(
|
||||
scenario,
|
||||
"请生成通知结果",
|
||||
options={
|
||||
"llm_provider": FakeProvider(),
|
||||
"batch_id": "SUB-20260604-004",
|
||||
"conversation_id": "conv-004",
|
||||
"product_name": "产品D",
|
||||
},
|
||||
)
|
||||
|
||||
assert result.notification_payload["notify_reason"] == "task_completed"
|
||||
|
||||
|
||||
def test_registration_word_export_report_preserves_formal_export_flag_and_blocked_items():
|
||||
scenario = {
|
||||
"id": "document_review",
|
||||
|
||||
@@ -170,6 +170,25 @@ def test_create_notification_record_persists_task_completed_and_task_failed(db):
|
||||
assert failed.notify_reason == "task_failed"
|
||||
|
||||
|
||||
def test_create_notification_record_rejects_unsupported_notify_reason(db):
|
||||
try:
|
||||
create_notification_record(
|
||||
batch_id="SUB-20260604-001",
|
||||
conversation_id="conv-001",
|
||||
product_name="产品A",
|
||||
trigger_source="risk_report",
|
||||
notify_reason="custom_reason",
|
||||
owner_role="注册资料负责人",
|
||||
feishu_user_id="ou_demo_1",
|
||||
message_status="sent",
|
||||
web_detail_url="https://example.com/detail/1",
|
||||
receipt={"message_id": "msg-1"},
|
||||
)
|
||||
assert False, "expected ValueError"
|
||||
except ValueError as exc:
|
||||
assert "notify_reason" in str(exc)
|
||||
|
||||
|
||||
def test_audit_list_supports_batch_and_product_filters(client, db):
|
||||
create_audit_log(
|
||||
"document_review",
|
||||
|
||||
Reference in New Issue
Block a user