- git mv stock-lab/ → stock/ - docker-compose.yml: 서비스 키 + container_name + build.context + frontend.depends_on + agent-office STOCK_LAB_URL → STOCK_URL - agent-office/app: config.py, service_proxy.py, agents/stock.py, tests/ STOCK_LAB_URL → STOCK_URL - nginx/default.conf: proxy_pass http://stock-lab → http://stock (3 lines) - CLAUDE.md / README.md / STATUS.md / scripts/ 문구 갱신 - stock/ 내부 자기 참조 갱신 lab 네이밍 정책 (feedback_lab_naming.md) graduation. API URL / Python import / DB 파일명 변경 없음.
37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
import datetime as dt
|
|
from unittest.mock import AsyncMock, patch
|
|
from fastapi.testclient import TestClient
|
|
|
|
from app.main import app
|
|
|
|
|
|
def test_refresh_news_sentiment_weekend_skip():
|
|
# 2026-05-16 = Saturday
|
|
client = TestClient(app)
|
|
resp = client.post(
|
|
"/api/stock/screener/snapshot/refresh-news-sentiment?asof=2026-05-16"
|
|
)
|
|
assert resp.status_code == 200
|
|
assert resp.json()["status"] == "skipped_weekend"
|
|
|
|
|
|
def test_refresh_news_sentiment_weekday_invokes_pipeline():
|
|
fake_summary = {
|
|
"asof": "2026-05-13", "updated": 3, "failures": [],
|
|
"duration_sec": 1.0, "tokens_input": 100, "tokens_output": 20,
|
|
"top_pos": [], "top_neg": [], "model": "m",
|
|
"mapping": {"total_articles": 5, "matched_pairs": 8, "hit_tickers": 3},
|
|
}
|
|
with patch("app.screener.router._ai_pipeline") as mp, \
|
|
patch("app.screener.router._ai_telegram") as mt:
|
|
mp.refresh_daily = AsyncMock(return_value=fake_summary)
|
|
mt.build_message = lambda **kw: f"TEXT_with_mapping={kw.get('mapping')}"
|
|
client = TestClient(app)
|
|
resp = client.post(
|
|
"/api/stock/screener/snapshot/refresh-news-sentiment?asof=2026-05-13"
|
|
)
|
|
assert resp.status_code == 200
|
|
body = resp.json()
|
|
assert body["mapping"]["hit_tickers"] == 3
|
|
assert "mapping=" in body["telegram_text"]
|