Files
daily_stock_analysis/tests/test_news_strategy_config.py
Alfred eaa25f8a26 [#697] fix: 新闻时效硬过滤与策略分窗 (#707)
* fix: enforce strict news freshness windows (#697)

* fix: normalize timezone-aware publish date parsing (#697)

* fix: align analyzer news window with runtime pipeline config (#697)
2026-03-16 22:40:45 +08:00

24 lines
851 B
Python

# -*- coding: utf-8 -*-
"""Tests for NEWS_STRATEGY_PROFILE parsing and effective window calculation."""
import unittest
from src.config import Config, resolve_news_window_days
class NewsStrategyConfigTestCase(unittest.TestCase):
def test_invalid_profile_fallback_to_short(self) -> None:
self.assertEqual(Config._parse_news_strategy_profile("bad_value"), "short")
def test_window_respects_news_max_age_days(self) -> None:
# medium=7 but max-age=3 -> effective=3
self.assertEqual(resolve_news_window_days(3, "medium"), 3)
# long=30 with max-age=30 -> effective=30
self.assertEqual(resolve_news_window_days(30, "long"), 30)
# ultra_short=1 with max-age=30 -> effective=1
self.assertEqual(resolve_news_window_days(30, "ultra_short"), 1)
if __name__ == "__main__":
unittest.main()