"""Settings env 로드 — 기본값 + override."""
from config import load_settings


def test_defaults(monkeypatch):
    for k in ("NAS_BASE_URL", "WEBAI_API_KEY", "REDIS_URL", "TM_KIS_APP_KEY",
              "TM_KIS_APP_SECRET", "TM_KIS_ACCOUNT", "TM_KIS_IS_VIRTUAL",
              "TM_LOOP_INTERVAL", "TM_CLIMAX_VOL_MULT"):
        monkeypatch.delenv(k, raising=False)
    s = load_settings()
    assert s.nas_base_url == "http://192.168.45.54:18500"
    assert s.redis_url == "redis://192.168.45.54:6379"
    assert s.kis_is_virtual is False
    assert s.loop_interval == 60
    assert s.climax_vol_mult == 3.0


def test_override(monkeypatch):
    monkeypatch.setenv("TM_KIS_IS_VIRTUAL", "1")
    monkeypatch.setenv("TM_LOOP_INTERVAL", "30")
    monkeypatch.setenv("TM_CLIMAX_VOL_MULT", "2.5")
    monkeypatch.setenv("WEBAI_API_KEY", "secret")
    s = load_settings()
    assert s.kis_is_virtual is True
    assert s.loop_interval == 30
    assert s.climax_vol_mult == 2.5
    assert s.webai_api_key == "secret"
