fix(signal_v2-phase3a): V1 KIS env pattern + test isolation fix

config.py: kis_env_type (virtual/real) + KIS_REAL_*/KIS_VIRTUAL_* env
variables (V1 호환). kis_app_key/kis_app_secret/kis_account properties
auto-select based on env type.

main.py: KIS not-configured warning uses descriptive message including
env type + expected var name.

test_main.py: monkeypatch load_dotenv to no-op + setenv empty string
(instead of delenv) — defeats .env re-read on importlib.reload.
Pre-existing test_startup_warns_if_webai_api_key_missing also fixed.

33/33 tests pass (was 31/33).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-16 10:25:58 +09:00
parent d85512d036
commit b690900cfc
3 changed files with 39 additions and 12 deletions

View File

@@ -38,7 +38,8 @@ async def lifespan(app: FastAPI):
)
if not settings.kis_app_key:
logger.warning(
"KIS_APP_KEY not configured — KIS REST/WebSocket disabled"
"KIS app_key not configured (KIS_ENV_TYPE=%s, KIS_%s_APP_KEY missing) — KIS REST/WebSocket disabled",
settings.kis_env_type, settings.kis_env_type.upper()
)
_ctx.client = StockClient(settings.stock_api_url, settings.webai_api_key)