"""Postgres integration test fixtures.""" from collections.abc import Generator import psycopg import pytest from python_repositories.config import PostgresConfig from tests.integration.postgres._containers import ( postgres_config_from_container, postgres_uri, raw_postgres_client_from_container, ) @pytest.fixture(scope="session") def postgres_container() -> Generator[str, None, None]: """Set up a Postgres container for testing and yield the Postgres URI.""" yield from postgres_uri() @pytest.fixture(scope="session") def postgres_config(postgres_container: str) -> PostgresConfig: """Provide PostgresConfig built from the test container.""" return postgres_config_from_container(postgres_container) @pytest.fixture(scope="session") def raw_postgres_client( postgres_container: str, ) -> Generator[psycopg.Connection, None, None]: """Provide a raw Postgres client connected to the test container.""" yield from raw_postgres_client_from_container(postgres_container)