from __future__ import annotations import os import pytest from fastapi.testclient import TestClient os.environ.setdefault("TOKEN_ENCRYPTION_KEY", "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef") os.environ.setdefault("PUBLIC_BASE_URL", "http://testserver") os.environ.setdefault("OIDC_CLIENT_ID", "test-oidc-client") os.environ.setdefault("OIDC_CLIENT_SECRET", "test-oidc-secret") os.environ.setdefault("ALLOWED_MCP_CLIENTS", "cursor|http://localhost:8787/callback") @pytest.fixture def client(tmp_path, monkeypatch): monkeypatch.setenv("DATA_DIR", str(tmp_path)) from app.config import get_settings get_settings.cache_clear() import app.main as main main._db = None with TestClient(main.app) as test_client: yield test_client @pytest.fixture def database(tmp_path, monkeypatch): monkeypatch.setenv("DATA_DIR", str(tmp_path)) from app.config import get_settings get_settings.cache_clear() import app.main as main main._db = None return main.db()