from pathlib import Path from utils.text_helpers import extract_snapshot_date_from_filename def test_extract_snapshot_date_from_filename_valid_date(): assert extract_snapshot_date_from_filename("即時業績_當日_20260111.xlsx") == "2026-01-11" def test_extract_snapshot_date_from_filename_rejects_invalid_date(): assert extract_snapshot_date_from_filename("即時業績_當日_20261399.xlsx") is None def test_import_routes_uses_shared_snapshot_date_helper(): source = Path("routes/import_routes.py").read_text(encoding="utf-8") assert "except:" not in source assert "extract_snapshot_date_from_filename as _extract_snapshot_date_from_filename" in source