"""Shared test fixtures for the SneakySwole test suite.""" import os from unittest.mock import patch import pytest from fastapi.testclient import TestClient @pytest.fixture(autouse=True) def _set_test_env() -> None: """Ensure required env vars are set for all tests.""" with patch.dict(os.environ, { "APP_ENV": "development", "DATABASE_URL": "sqlite:///data/test_sneakyswole.db", }, clear=False): yield @pytest.fixture def client() -> TestClient: """Create a FastAPI TestClient for integration tests.""" from app.main import create_app app = create_app() return TestClient(app) def set_profile_cookie(client: TestClient, profile_id: int) -> None: """Helper to set the active_profile_id cookie on a test client.""" client.cookies.set("active_profile_id", str(profile_id))