Files
feiqiu-ETL/etl_billiards/tests/unit/test_reporting.py
2025-11-30 07:19:05 +08:00

23 lines
827 B
Python

# -*- coding: utf-8 -*-
"""汇总与报告工具的单测。"""
from utils.reporting import summarize_counts, format_report
def test_summarize_counts_and_format():
task_results = [
{"task_code": "ORDERS", "counts": {"fetched": 2, "inserted": 2, "updated": 0, "skipped": 0, "errors": 0}},
{"task_code": "PAYMENTS", "counts": {"fetched": 3, "inserted": 2, "updated": 1, "skipped": 0, "errors": 0}},
]
summary = summarize_counts(task_results)
assert summary["total"]["fetched"] == 5
assert summary["total"]["inserted"] == 4
assert summary["total"]["updated"] == 1
assert summary["total"]["errors"] == 0
assert len(summary["details"]) == 2
report = format_report(summary)
assert "TOTAL fetched=5" in report
assert "ORDERS:" in report
assert "PAYMENTS:" in report