feat(api): 新增 SRE 戰情室 digest preview
This commit is contained in:
@@ -318,6 +318,46 @@ class TestFormatDailyReport:
|
||||
assert "Verifier: source_health_ready 1/2" in report
|
||||
assert "不代表已授權發送或自動修復" in report
|
||||
|
||||
def test_sre_digest_preview_contains_assets_and_boundaries(self):
|
||||
"""SRE 戰情室 digest 應收斂缺口、資產與 no-send 邊界"""
|
||||
source_health = {
|
||||
"rollups": {
|
||||
"source_ok_count": 2,
|
||||
"source_count": 5,
|
||||
"source_gap_count": 3,
|
||||
"confidence_percent": 40,
|
||||
"no_send_preview_count": 3,
|
||||
},
|
||||
"source_health": [
|
||||
{"work_item_id": "report-source-gap:incident_summary"},
|
||||
],
|
||||
"work_items": [
|
||||
{"work_item_id": "report-source-gap:incident_summary"},
|
||||
{"work_item_id": "report-source-gap:ai_performance"},
|
||||
],
|
||||
"automation_assets": [
|
||||
{"label": "KM", "state": "draft_ready", "done_count": 3, "blocked_count": 2},
|
||||
{"label": "PlayBook", "state": "draft_required", "done_count": 0, "blocked_count": 2},
|
||||
{"label": "Verifier", "state": "source_health_ready", "done_count": 1, "blocked_count": 2},
|
||||
],
|
||||
}
|
||||
svc = ReportGenerationService()
|
||||
report = svc.format_sre_digest_preview(
|
||||
source_health,
|
||||
generated_at=datetime(2026, 6, 18, 10, 0, tzinfo=_TZ_TAIPEI),
|
||||
)
|
||||
|
||||
assert "AwoooI SRE 戰情室 digest no-send preview" in report
|
||||
assert "來源: <code>2/5</code>" in report
|
||||
assert "report-source-gap:incident_summary" in report
|
||||
assert "live Telegram send: 0" in report
|
||||
assert "Gateway queue write: 0" in report
|
||||
assert "KM: draft_ready 3/5" in report
|
||||
assert "PlayBook: draft_required 0/2" in report
|
||||
assert "Verifier: source_health_ready 1/3" in report
|
||||
assert "不發 Telegram" in report
|
||||
assert "不啟動 runtime gate" in report
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# format_postmortem
|
||||
|
||||
@@ -70,3 +70,31 @@ def test_monthly_report_preview_exposes_source_health_no_send_preview():
|
||||
assert f"來源: <code>{data['source_ok_count']}/{data['source_total_count']}</code>" in preview
|
||||
assert "實發: 0" in preview
|
||||
assert "不代表已授權發送或自動修復" in preview
|
||||
|
||||
|
||||
def test_sre_digest_preview_exposes_source_health_no_send_preview():
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/v1/stats/sre-digest/preview")
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "report_date" in data
|
||||
assert "source_ok_count" in data
|
||||
assert "source_total_count" in data
|
||||
assert "source_confidence_percent" in data
|
||||
assert "source_gap_ids" in data
|
||||
assert "no_send_preview_count" in data
|
||||
assert "live_send_allowed_count" in data
|
||||
assert "runtime_gate_count" in data
|
||||
assert "formatted_preview" in data
|
||||
assert data["live_send_allowed_count"] == 0
|
||||
assert data["runtime_gate_count"] == 0
|
||||
|
||||
preview = data["formatted_preview"]
|
||||
assert "AwoooI SRE 戰情室 digest no-send preview" in preview
|
||||
assert "報表資料源 / 沉澱" in preview
|
||||
assert f"來源: <code>{data['source_ok_count']}/{data['source_total_count']}</code>" in preview
|
||||
assert "live Telegram send: 0" in preview
|
||||
assert "Gateway queue write: 0" in preview
|
||||
assert "不發 Telegram" in preview
|
||||
assert "不啟動 runtime gate" in preview
|
||||
|
||||
Reference in New Issue
Block a user