Skip to content

Testing EN

northrails edited this page Jul 21, 2026 · 1 revision

繁體中文版

Testing — tests/

Run with pytest (configured via pyproject.toml, testpaths = ["tests"]). Proves genericity with deliberately trivial, made-up business logic (a "widget count per warehouse" pipeline) plus the e-commerce domain layer, and exercises the opt-in logging layer against both.

File Purpose
test_generic_pipeline_integration.py End-to-end proof that pipeline/ is genuinely generic: wires a "widget count per warehouse" pipeline with nothing session/order/customer-shaped, via run_local/build_pipeline
test_pipeline_logging.py Proves the opt-in enable_logging=True wiring (execution_log + stage_timing) using the same generic "widget count" logic
test_ecommerce_pipeline_integration.py End-to-end run of build_ecommerce_pipeline via run_local, asserting on the written JSONL outputs
test_ecommerce_metrics.py Unit tests for compute_daily_metrics (typical values, zero-order, zero-session edge cases)
test_order_policies.py Unit tests for exclude_cancelled_and_returned, accept_all_orders, partition_by_policy
test_leak_guard.py Unit tests for LeakGuard/assert_safe/is_safe — forbidden-key detection, allow-list exceptions
test_cloud_gate.py Unit tests for assert_gates_open — all-flags-pass, missing flag, wrong confirmation string
test_execution_log.py Unit tests for build_execution_log_event/exception_event — schema validation, exception-type-only exposure
test_stage_timing.py Unit tests for StageTimer/build_stage_timing_event/summarize_stage_durations
test_dataflow_evidence.py Unit tests for job_url/console_url/extract_user_counter (URL building, counter extraction from a mocked response)
test_dataflow_logs.py Unit tests for the Cloud Logging reader (mocked HTTP responses, pagination)
__init__.py Empty — marks tests/ as a package so pythonpath = ["."] imports resolve

Run everything:

pytest

Clone this wiki locally