-
Notifications
You must be signed in to change notification settings - Fork 0
Testing ZH
northrails edited this page Jul 21, 2026
·
1 revision
以 pytest 執行(設定於 pyproject.toml,testpaths = ["tests"])。以刻意瑣碎、虛構的商業邏輯(「各倉庫的小工具數量」管線)證明通用性,並涵蓋電商領域層,同時對兩者都驗證了選用的日誌記錄層。
| 檔案 | 功能 |
|---|---|
test_generic_pipeline_integration.py |
端對端證明 pipeline/ 確實通用:透過 run_local/build_pipeline 組裝一個與 session/order/customer 完全無關的「倉庫小工具數量」管線 |
test_pipeline_logging.py |
使用同一組通用的「小工具數量」邏輯,證明選用的 enable_logging=True 接線(execution_log + stage_timing)正常運作 |
test_ecommerce_pipeline_integration.py |
透過 run_local 端對端執行 build_ecommerce_pipeline,驗證寫出的 JSONL 輸出內容 |
test_ecommerce_metrics.py |
compute_daily_metrics 的單元測試(典型數值、零訂單、零 session 等邊界情境) |
test_order_policies.py |
exclude_cancelled_and_returned、accept_all_orders、partition_by_policy 的單元測試 |
test_leak_guard.py |
LeakGuard/assert_safe/is_safe 的單元測試——禁用鍵值偵測、允許清單例外 |
test_cloud_gate.py |
assert_gates_open 的單元測試——全部旗標通過、缺少旗標、確認字串錯誤等情境 |
test_execution_log.py |
build_execution_log_event/exception_event 的單元測試——schema 驗證、只揭露例外類型 |
test_stage_timing.py |
StageTimer/build_stage_timing_event/summarize_stage_durations 的單元測試 |
test_dataflow_evidence.py |
job_url/console_url/extract_user_counter 的單元測試(URL 組建、從模擬回應中擷取 counter) |
test_dataflow_logs.py |
Cloud Logging 讀取器的單元測試(模擬 HTTP 回應、分頁) |
__init__.py |
空檔案——將 tests/ 標記為套件,讓 pythonpath = ["."] 的匯入能正確解析 |
執行全部測試:
pytest