atlas-iac/testing/tests/conftest.py

41 lines
1.4 KiB
Python
Raw Permalink Normal View History

"""Shared pytest boundaries and runtime-path fixtures for repository tests."""
from __future__ import annotations
2026-08-17 08:16:35 -03:00
import sys
from pathlib import Path
import pytest
@pytest.fixture(autouse=True)
def isolate_coordinator_gitea_token(
request: pytest.FixtureRequest,
monkeypatch: pytest.MonkeyPatch,
tmp_path: Path,
) -> None:
"""Prevent coordinator tests from observing the mounted production token."""
if request.node.path.name == "test_hermes_coordinator.py":
monkeypatch.setenv(
"HERMES_GITEA_TOKEN_FILE", str(tmp_path / "absent-gitea-token")
)
2026-08-17 08:16:35 -03:00
@pytest.fixture(autouse=True)
def _patched_hermes_cli_db_contract(request, monkeypatch):
"""Keep legacy lane test doubles focused on their original safety boundary."""
module_name = request.module.__name__.rsplit(".", 1)[-1]
if not module_name.startswith("test_hermes_cli_") or module_name.endswith(
"capabilities"
):
return
capability_module = sys.modules.get("cli_lane_capabilities")
if capability_module is None:
return
safe = capability_module.KanbanCapabilities(True, True, True)
for name, module in tuple(sys.modules.items()):
if (
name == "cli_lane_runner" or name.startswith("cli_lane_")
) and hasattr(module, "kanban_capabilities"):
monkeypatch.setattr(module, "kanban_capabilities", lambda _db: safe)