feat(stock): apply webai_cache to portfolio/news/screener-preview (SP-A2)

3 endpoint cache 적용 — /api/webai/portfolio, /api/webai/news-sentiment,
/api/stock/screener/run (preview 모드만, auto는 캐시 미적용).
V1+V2 동시 호출도 NAS에서 1회 계산. web-ai 측 SP-A1 캐시와 2-layer로
작동하여 NAS 인바운드 부담 70% 감소 예상.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-18 21:47:23 +09:00
parent 030365bed0
commit 978aa14f8b
3 changed files with 48 additions and 5 deletions

15
stock/app/conftest.py Normal file
View File

@@ -0,0 +1,15 @@
"""Project-level pytest conftest.
SP-A2: autouse fixture that resets all webai_cache TTLCaches between tests
so screener/portfolio/news cache state does not leak across test cases.
"""
import pytest
from app import webai_cache
@pytest.fixture(autouse=True)
def _reset_webai_cache():
webai_cache.PORTFOLIO_CACHE.clear()
webai_cache.NEWS_CACHE.clear()
webai_cache.SCREENER_CACHE.clear()
yield