"""Shared fixtures for the govtool test suite. The ``repo`` fixture builds a complete, self-contained governed repository in a temp directory: the real shipped constitution source tree, a fresh citizen registry with locally generated keypairs, and empty ``proposals/`` and ``ledger/`` directories. Every test gets an isolated polity; nothing in the project tree is mutated. """ from __future__ import annotations import shutil import pytest from tests import helpers from tests.helpers import PROJECT_ROOT, generate_keypair, write_registry CITIZEN_NAMES = ["alice", "bob", "carol", "dave", "erin", "frank"] @pytest.fixture() def citizens(): """Six citizens with fresh ed25519 keypairs.""" out = [] for name in CITIZEN_NAMES: private_key, public_key = generate_keypair() out.append( { "id": f"cit-{name}", "name": name.capitalize(), "private_key": private_key, "public_key": public_key, "status": "active", "joined": "2025-01-01", } ) return out @pytest.fixture() def repo(tmp_path, citizens): """An isolated governed repository: constitution + registry + ledger dirs.""" dest = tmp_path / "polity" shutil.copytree(PROJECT_ROOT / "constitution", dest / "constitution") write_registry(dest / "citizens" / "registry.yaml", citizens) (dest / "proposals").mkdir(parents=True, exist_ok=True) (dest / "ledger").mkdir(parents=True, exist_ok=True) return dest @pytest.fixture() def registry_path(repo): return repo / "citizens" / "registry.yaml" @pytest.fixture() def eligible_ids(citizens): return [c["id"] for c in citizens] @pytest.fixture(scope="session") def project_root(): return PROJECT_ROOT def pytest_report_header(config): return f"fablepool govtool suite — adapter layer: tests/helpers.py — repo: {PROJECT_ROOT}"