"""Pytest fixtures for Palladium tests."""

from __future__ import annotations

import os
import sys
from pathlib import Path

import pytest

ROOT = Path(__file__).resolve().parent.parent
if str(ROOT) not in sys.path:
    sys.path.insert(0, str(ROOT))


@pytest.fixture(autouse=True)
def _env(monkeypatch):
    """Default test env vars so TEIClient() doesn't need a real .env."""
    monkeypatch.setenv("ATHENA_BASE_URL", "https://athena.test")
    monkeypatch.setenv("ATHENA_API_KEY", "test-key")


@pytest.fixture
def amazon_connect_seed():
    """Load the Amazon Connect study's verbatim anchor (post-migration the
    study is self-contained; teicalc is stdlib-only, so importing it here
    needs no study venv — the row shape matches the old seed_data)."""
    from types import SimpleNamespace

    sys.path.insert(0, str(ROOT / "studies" / "202602_TEI_Amazon_Connect"))
    try:
        from teicalc import anchor  # type: ignore[import-not-found]
        return SimpleNamespace(BENEFITS=anchor.BENEFITS_VERBATIM,
                               COSTS=anchor.COSTS_VERBATIM)
    finally:
        # Leave the path alone — many tests will use the seed
        pass
