from __future__ import annotations import os import pytest # Set before anything imports poorbird.config, whose Settings are cached. os.environ.setdefault("POORBIRD_LOG_LEVEL", "WARNING") os.environ.setdefault("POORBIRD_IMAGE_ROOT", "/tmp/poorbird-test/images") os.environ.setdefault("POORBIRD_THUMB_ROOT", "/tmp/poorbird-test/thumbs") os.environ.setdefault("POORBIRD_STATE_DIR", "/tmp/poorbird-test/state") def database_is_reachable() -> bool: try: from sqlalchemy import text from poorbird.db import engine with engine.connect() as conn: conn.execute(text("SELECT 1")) return True except Exception: return False needs_db = pytest.mark.skipif( not database_is_reachable(), reason="no reachable PostgreSQL (set POORBIRD_DATABASE_URL)", ) @pytest.fixture(scope="session") def client(): from fastapi.testclient import TestClient from poorbird.api.app import create_app with TestClient(create_app()) as c: yield c