"""Shared fixtures for e2e tests — dataset discovery + skip markers."""

from pathlib import Path

import pytest

REPO_ROOT = Path(__file__).resolve().parents[2]
DATASETS_ROOT = REPO_ROOT / "datasets"


def _euroc_mh_root(seq: str) -> Path:
    """Return path for a MH sequence, skipping if absent."""
    root = DATASETS_ROOT / "euroc" / seq
    if not (root / "mav0").is_dir():
        pytest.skip(
            f"EuRoC {seq} not present at {root}. "
            "Fetch the Machine Hall bundle from ETH Research Collection "
            f"(DOI 10.3929/ethz-b-000690084), unpack the inner {seq}_*.zip "
            f"into {root}/ so that {root}/mav0/ exists."
        )
    return root


@pytest.fixture(scope="session")
def euroc_mh01_root() -> Path:
    return _euroc_mh_root("MH_01")


@pytest.fixture(scope="session")
def euroc_mh02_root() -> Path:
    return _euroc_mh_root("MH_02")


@pytest.fixture(scope="session")
def euroc_mh03_root() -> Path:
    return _euroc_mh_root("MH_03")


@pytest.fixture(scope="session")
def euroc_mh04_root() -> Path:
    return _euroc_mh_root("MH_04")


@pytest.fixture(scope="session")
def euroc_mh05_root() -> Path:
    return _euroc_mh_root("MH_05")


@pytest.fixture(scope="session")
def vpair_sample_root() -> Path:
    root = DATASETS_ROOT / "vpair" / "sample"
    if not (root / "poses_query.txt").is_file():
        pytest.skip(
            f"VPAIR sample not present at {root}. "
            "Download the sample zip from the Zenodo link on "
            "https://github.com/AerVisLoc/vpair, then unpack so that "
            f"{root}/poses_query.txt exists."
        )
    return root


@pytest.fixture(scope="session")
def mars_lvig_root() -> Path:
    root = DATASETS_ROOT / "mars_lvig"
    if not root.is_dir():
        pytest.skip(f"MARS-LVIG not present at {root}.")
    return root
