Files
ewoooc/tests/test_telegram_triaged_alert_format.py
OoO 91601da3f8
All checks were successful
CD Pipeline / deploy (push) Successful in 1m6s
[V10.289] 重排 EA HITL Telegram 告警格式 | telegram_templates.py
2026-05-19 23:35:16 +08:00

44 lines
1.9 KiB
Python
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from services.telegram_templates import triaged_alert
def test_ea_escalation_uses_structured_incident_brief():
msg, keyboard = triaged_alert(
base_event={
"event_type": "ea_escalation",
"title": "🐘 EA 升級審核 · 價格下滑警報",
"summary": "自主決策信心度 0.82 低於門檻,需人工批准",
"id": "ea_review_test",
},
tier_label="🐘 Elephant Alpha · L3 HITL",
ai_summary=(
"分析顯示 5 個代表性 SKU 的價格差異分別為 16.7%~38.3%"
"且每件價差至多 370 元。"
),
ai_cause="觸發類型:價格下滑警報 | 信心度0.82 | 參與模組Hermes, NemoTron",
ai_actions=[
"[5900068] [derma Angel 護妍天使] 集中抗痘精華|"
"MOMO $300 vs PChome $250 (+16.7%)"
"每件價差 NT$ 50"
"建議人工確認 PChome identity_v2 後評估跟價或促銷|"
"PChome DABC53-A9009OEF",
"[3518670] L'Occitane 歐舒丹 官方直營 乳油木|"
"MOMO $1,220 vs PChome $850 (+30.3%)"
"每件價差 NT$ 370"
"建議人工確認 PChome identity_v2 後評估跟價或促銷|"
"PChome DDADKS-A900HIG5Y",
],
)
assert "🧭 <b>決策狀態</b>" in msg
assert "📊 <b>風險摘要</b>" in msg
assert "📋 <b>TOP 待審 SKU</b>" in msg
assert "✅ <b>建議處置</b>" in msg
assert "• 待審 SKU<b>2</b> 件" in msg
assert "• 價差範圍:<b>+16.7%+30.3%</b>" in msg
assert "• 最大單件價差:<b>NT$ 370</b>" in msg
assert "<b>1. [5900068]" in msg
assert "MOMO<b>$300</b> PChome<b>$250</b>" in msg
assert "PChome<code>DABC53-A9009OEF</code>" in msg
assert " • [5900068]" not in msg
assert keyboard["inline_keyboard"][0][0]["callback_data"] == "momo:eig:ea_review_test"