Files
daily_stock_analysis/tests/test_yfinance_normalize.py
mumu 647b9d24e5 fix: support Longbridge OAuth token cache (#1490)
* fix: support Longbridge OAuth token cache

* fix(review-feedback-1490): bump the runtime dependency minimum or fail with a clear upgrade

* fix(review-feedback-1490): 补充对应回归测试

* fix(review-feedback-1490): Point OAuth cache at the dsa home in Docker

* fix(review-feedback-1490): 修复或给出明确的 CI 重跑通过证据

* fix(review-feedback-1490): 处理 Docker/Actions 持久化 token cache 已损坏时无法被新的 LONGBRIDGE OAUTH TOKEN

* fix: tighten Longbridge OAuth compatibility

* fix: refresh stale Longbridge OAuth cache

* fix: guard Longbridge OAuth SDK availability
2026-05-29 23:08:16 +08:00

27 lines
811 B
Python

# -*- coding: utf-8 -*-
"""Regression tests for YfinanceFetcher daily data normalization."""
import pandas as pd
from data_provider.yfinance_fetcher import YfinanceFetcher
def test_normalize_daily_data_recovers_unnamed_datetime_index_date_column() -> None:
fetcher = YfinanceFetcher()
raw = pd.DataFrame(
{
"Open": [10.0, 10.5],
"High": [11.0, 11.2],
"Low": [9.8, 10.1],
"Close": [10.8, 11.0],
"Volume": [1000, 1200],
},
index=pd.DatetimeIndex(["2026-05-25", "2026-05-26"]),
)
normalized = fetcher._normalize_data(raw, "DRAM")
cleaned = fetcher._clean_data(normalized)
assert "date" in normalized.columns
assert cleaned["date"].dt.strftime("%Y-%m-%d").tolist() == ["2026-05-25", "2026-05-26"]