"""Pytest fixtures for the Access -> SQL Server sync integration tests. Credential safety: the SQL connection string is read from the gitignored ``config.yaml`` via ``sync.config.load_config``. No password is ever hardcoded in a committed file. The ``.sql`` artefacts contain no credentials. """ import os import pytest import pyodbc from sync.config import load_config @pytest.fixture def sql_conn(): """A pyodbc connection to the CompanyDB SQL Server. Skipped unless ``RUN_INTEGRATION=1`` is set. The connection is opened in a transaction (autocommit=False); each test owns its commit/rollback and is responsible for cleaning up any temporary objects it creates. """ if not os.environ.get("RUN_INTEGRATION"): pytest.skip("set RUN_INTEGRATION=1 to run SQL integration tests") cfg = load_config("config.yaml") # gitignored, real creds conn = pyodbc.connect(cfg.sql_server.conn_str, autocommit=False) try: yield conn finally: conn.rollback() conn.close()