Files
ewoooc/tests/test_snapshot_date_helpers.py
OoO 317ff1bf02
All checks were successful
CD Pipeline / deploy (push) Successful in 57s
共用匯入檔名日期解析
2026-05-13 09:58:56 +08:00

19 lines
686 B
Python

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