feat(signal_v2): stock_client + 6 integration tests

httpx async client with custom retry loop (max 3, exponential 1s/2s/4s),
memory dict cache (portfolio 60s / news-sentiment 300s / screener 60s),
X-WebAI-Key auth header injection. Stale fallback returns last
successful response with logger.warning on persistent failures.

6 integration tests pass with respx httpx mock.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-16 03:40:12 +09:00
parent 8a2fac03a6
commit 8469bf7ffa
5 changed files with 320 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
"""Pytest fixtures for signal_v2 tests."""
from pathlib import Path
import pytest
import respx
@pytest.fixture
def tmp_dedup_db(tmp_path) -> Path:
"""SQLite 단위 테스트용 임시 DB path."""
return tmp_path / "test_signal_v2.db"
@pytest.fixture
def mock_stock_api():
"""respx 로 stock API mock. base_url 은 테스트마다 임의."""
with respx.mock(base_url="https://test.stock.local", assert_all_called=False) as mock:
yield mock