"""Monorepo test bootstrap — make sibling packages importable. After lambdagent moved to src-layout (``lambdagent/src/lambdagent``), we need TWO entries on sys.path: 1. Monorepo root — so ``from agentpaas.X``, ``from agentexample.X``, ``from lambdagent_guard.X`` (other siblings) resolve. 2. ``lambdagent/src`` — so ``from lambdagent.X`` resolves directly to the local source tree instead of requiring ``pip install -e .``. The pip-install path is still preferred for production (see setup.sh and Dockerfile); this conftest only smoothes local ``pytest tests/`` runs during development. """ import os import sys _MONOREPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) _LAMBDAGENT_SRC = os.path.join(_MONOREPO_ROOT, "lambdagent", "src") # Order matters: src first (more specific), monorepo root second. for _p in (_LAMBDAGENT_SRC, _MONOREPO_ROOT): if _p not in sys.path: sys.path.insert(0, _p) # Critical: disable startup-time auto-bootstrap during tests. # Without this, every `TestClient(app)` would fire the desktop bootstrap # hook, write a fresh API key to the developer's real # ~/.agentpaas/config.json, and pollute the system DB with phantom tenants. # Tests that want to exercise the bootstrap path do so explicitly via # `auto_bootstrap_desktop()` with CONFIG_FILE patched to a tmp path # (see test_deployment_mode.py). os.environ.setdefault("AGENTPAAS_TESTING", "1")