import itertools import pytest from testcontainers.postgres import PostgresContainer from agent.config import AgentConfig _db_counter = itertools.count() @pytest.fixture(scope="session") def pg(): with PostgresContainer("postgres:16-alpine") as container: yield container @pytest.fixture def cfg(pg) -> AgentConfig: """AgentConfig pointing at a fresh, uniquely named database per test.""" return AgentConfig( db_host=pg.get_container_host_ip(), db_port=int(pg.get_exposed_port(5432)), db_user=pg.username, db_password=pg.password, agent_db_name=f"agentdb_test_{next(_db_counter)}", firefly_url="http://firefly.test", firefly_token="test-token", heartbeat_interval_minutes=60, )