import pytest from fastapi.testclient import TestClient KEY = "test-key" @pytest.fixture def client(tmp_path, monkeypatch): monkeypatch.setenv("DB_PATH", str(tmp_path / "test.db")) monkeypatch.setenv("API_KEY", KEY) # Midday sun at this position so silent inverters count as offline monkeypatch.setenv("SITE_LATITUDE", "0") monkeypatch.setenv("SITE_LONGITUDE", "0") monkeypatch.setenv("DAYLIGHT_MIN_ELEVATION", "-90") from app.config import get_settings get_settings.cache_clear() from app.main import app with TestClient(app) as c: c.headers["X-API-Key"] = KEY yield c get_settings.cache_clear()