"""Settings env 로드."""
from config import load_settings


def test_defaults(monkeypatch):
    for k in ("NAS_BASE_URL", "INTERNAL_API_KEY", "REDIS_URL", "FETCH_INTERVAL_HOURS",
              "DAYTIME_START", "DAYTIME_END", "NAVER_REAL_ESTATE_TYPE",
              "NAVER_TOKEN_URL", "NAVER_HEADLESS"):
        monkeypatch.delenv(k, raising=False)
    s = load_settings()
    assert s.nas_base_url == "http://192.168.45.54:18500"
    assert s.fetch_interval_hours == 2.5
    assert s.daytime_start == "08:00" and s.daytime_end == "20:00"
    assert s.naver_headless is True
    assert "new.land.naver.com" in s.naver_token_url


def test_override(monkeypatch):
    monkeypatch.setenv("INTERNAL_API_KEY", "sekret")
    monkeypatch.setenv("FETCH_INTERVAL_HOURS", "3")
    monkeypatch.setenv("NAVER_HEADLESS", "0")
    s = load_settings()
    assert s.internal_api_key == "sekret"
    assert s.fetch_interval_hours == 3.0
    assert s.naver_headless is False
