diff --git a/tests/test_risk_chat_tools.py b/tests/test_risk_chat_tools.py index 2980b40..ea5a8d4 100644 --- a/tests/test_risk_chat_tools.py +++ b/tests/test_risk_chat_tools.py @@ -55,6 +55,11 @@ def risk_env(monkeypatch): " VALUES ('P-001', '稳健一号', 'R1', 'fund')," " ('P-002', '高风权益', 'R5', 'fund')") ) + # advisor 归属:STAFF-10086 与 CUST-9527 active(CUST-1001 无归属,验证 NOT_ASSIGNED) + conn.execute( + text("INSERT INTO core_customer_advisor (advisor_id, customer_id, rel_status)" + " VALUES ('STAFF-10086', 'CUST-9527', 'active')") + ) # 预警:CUST-9527 今日 pending(ALERT-001)+ 昨日 pending(ALERT-002) conn.execute( text("INSERT INTO risk_alert (alert_id, trace_id, customer_id, trade_id, alert_type," @@ -231,6 +236,34 @@ def test_suitability_check_unknown_param_blocked(risk_env): assert record["status"] == "blocked" and record["error_code"] == "TOOL_BAD_PARAM" +def test_suitability_check_empty_product_id_not_found(risk_env): + """空 product_id 经白名单放行但产品缺失 → 结构化 found=False(不抛异常污染对话)。""" + record = tool_service.run_tool( + tool_name="suitability_check", agent_type="customer", actor=ACTOR_CUSTOMER, + customer_id="CUST-9527", tool_input={"product_id": ""}, session_id="sess-s5", + ) + assert record["status"] == "success" and record["data"]["found"] is False + + +# ---------- advisor 分支归属(评审 P2:锁死 agent 分支) ---------- + + +def test_advisor_assigned_customer_success(risk_env): + record = tool_service.run_tool( + tool_name="customer_context", agent_type="advisor", actor=ACTOR_ADVISOR, + customer_id="CUST-9527", session_id="sess-ad1", + ) + assert record["status"] == "success" and record["data"]["found"] is True + + +def test_advisor_not_assigned_blocked(risk_env): + record = tool_service.run_tool( + tool_name="customer_context", agent_type="advisor", actor=ACTOR_ADVISOR, + customer_id="CUST-1001", session_id="sess-ad2", + ) + assert record["status"] == "blocked" and record["error_code"] == "AUTH_403_NOT_ASSIGNED" + + # ---------- aml_lookup ----------