fix(api): 在日報月報 preview 顯示資料源沉澱
This commit is contained in:
@@ -3,6 +3,29 @@ from fastapi.testclient import TestClient
|
||||
from src.main import app
|
||||
|
||||
|
||||
def test_daily_report_preview_exposes_source_health_no_send_preview():
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/v1/stats/daily/preview")
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "report_date" in data
|
||||
assert "alert_total" in data
|
||||
assert "km_new_entries" in data
|
||||
assert "playbook_count" 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 "formatted_preview" in data
|
||||
|
||||
preview = data["formatted_preview"]
|
||||
assert "AWOOOI 日度巡檢報告" in preview
|
||||
assert "報表資料源 / 沉澱" in preview
|
||||
assert f"來源: <code>{data['source_ok_count']}/{data['source_total_count']}</code>" in preview
|
||||
assert "不自動改排程" in preview
|
||||
|
||||
|
||||
def test_weekly_report_preview_exposes_source_health_no_send_preview():
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/v1/stats/weekly/preview")
|
||||
@@ -25,3 +48,25 @@ def test_weekly_report_preview_exposes_source_health_no_send_preview():
|
||||
assert "報表資料源 / 沉澱" in preview
|
||||
assert f"來源: <code>{data['source_ok_count']}/{data['source_total_count']}</code>" in preview
|
||||
assert "不自動改排程" in preview
|
||||
|
||||
|
||||
def test_monthly_report_preview_exposes_source_health_no_send_preview():
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/v1/stats/monthly/preview")
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "report_month" 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 "formatted_preview" in data
|
||||
|
||||
preview = data["formatted_preview"]
|
||||
assert "月報 no-send preview" in preview
|
||||
assert "報表資料源 / 沉澱" in preview
|
||||
assert f"來源: <code>{data['source_ok_count']}/{data['source_total_count']}</code>" in preview
|
||||
assert "實發: 0" in preview
|
||||
assert "不代表已授權發送或自動修復" in preview
|
||||
|
||||
Reference in New Issue
Block a user