feat(awooop): link telegram alerts to incident runs
This commit is contained in:
@@ -6,6 +6,7 @@ from src.services.platform_operator_service import (
|
||||
_list_filter_context_limit,
|
||||
_outbound_timeline_title,
|
||||
_run_remediation_list_summary,
|
||||
_remediation_summary_matches_incident_id,
|
||||
_remediation_summary_matches_status,
|
||||
_remediation_timeline_summary,
|
||||
_timeline_sort_key,
|
||||
@@ -172,6 +173,18 @@ def test_remediation_summary_matches_status_filter() -> None:
|
||||
assert _remediation_summary_matches_status(None, "no_evidence")
|
||||
|
||||
|
||||
def test_remediation_summary_matches_incident_id_filter() -> None:
|
||||
assert _remediation_summary_matches_incident_id(
|
||||
{"incident_ids": ["INC-20260514-F85F21"]},
|
||||
"INC-20260514-F85F21",
|
||||
)
|
||||
assert not _remediation_summary_matches_incident_id(
|
||||
{"incident_ids": ["INC-20260514-F85F21"]},
|
||||
"INC-20260513-79ED5E",
|
||||
)
|
||||
assert _remediation_summary_matches_incident_id(None, None)
|
||||
|
||||
|
||||
def test_list_filter_context_limit_scales_with_candidate_rows() -> None:
|
||||
assert _list_filter_context_limit(2) == 500
|
||||
assert _list_filter_context_limit(4176) == 16704
|
||||
|
||||
@@ -71,6 +71,42 @@ def test_telegram_html_chunks_preserve_complete_lines() -> None:
|
||||
assert all(chunk.count("<b>") == chunk.count("</b>") for chunk in chunks)
|
||||
|
||||
|
||||
def test_awooop_runs_url_for_incident_uses_public_incident_filter() -> None:
|
||||
"""Telegram URL button 必須導到公開 AwoooP Run list,並帶 incident filter。"""
|
||||
url = telegram_gateway_module._awooop_runs_url_for_incident("INC-20260514-F85F21")
|
||||
|
||||
assert url == (
|
||||
"https://awoooi.wooo.work/zh-TW/awooop/runs"
|
||||
"?project_id=awoooi&incident_id=INC-20260514-F85F21"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_build_inline_keyboard_includes_awooop_deep_link() -> None:
|
||||
"""主告警卡的 read-only 按鈕列要能回到 AwoooP evidence view。"""
|
||||
gateway = TelegramGateway()
|
||||
|
||||
keyboard = await gateway._build_inline_keyboard(
|
||||
approval_id="INC-20260514-F85F21",
|
||||
include_auto_tuning=False,
|
||||
incident_id="INC-20260514-F85F21",
|
||||
)
|
||||
buttons = [
|
||||
button
|
||||
for row in keyboard["inline_keyboard"]
|
||||
for button in row
|
||||
]
|
||||
|
||||
awooop_buttons = [button for button in buttons if button["text"] == "🧭 AwoooP"]
|
||||
assert awooop_buttons == [{
|
||||
"text": "🧭 AwoooP",
|
||||
"url": (
|
||||
"https://awoooi.wooo.work/zh-TW/awooop/runs"
|
||||
"?project_id=awoooi&incident_id=INC-20260514-F85F21"
|
||||
),
|
||||
}]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_send_html_line_message_falls_back_to_plain_text_on_parse_error(monkeypatch):
|
||||
"""Telegram HTML parse 400 時要送純文字 fallback,不可回報成歷史查詢失敗。"""
|
||||
|
||||
Reference in New Issue
Block a user