"""Shared fixtures for unit + integration tests.""" from __future__ import annotations from collections.abc import Iterator import pytest from fastapi.testclient import TestClient from sqlalchemy.orm import Session from app.db import SessionLocal, db_available from app.main import app as fastapi_app @pytest.fixture() def client() -> TestClient: return TestClient(fastapi_app) @pytest.fixture() def db() -> Iterator[Session]: """Real Postgres session (``podman compose up -d db``). Skips with clear instructions when the database is not running, so the suite degrades gracefully on a machine without the stack started. """ if not db_available(): pytest.skip("Postgres not reachable — run `podman compose up -d db` first") session = SessionLocal() try: yield session finally: session.close()