#!/usr/bin/python3
"""Shared pytest fixtures for slpkg test suite."""

import pytest

# ---------------------------------------------------------------------------
# Minimal repository data used across multiple test modules.
# Each package has the subset of keys actually touched by the code under test.
# ---------------------------------------------------------------------------
SAMPLE_DATA: dict[str, dict[str, str]] = {
    "ffmpeg": {
        "version": "7.1",
        "build": "1",
        "arch": "x86_64",
        "requires": ["libvpx", "x264"],
        "repo": "alien",
        "package": "ffmpeg-7.1-x86_64-1alien.txz",
    },
    "libvpx": {
        "version": "1.13.1",
        "build": "1",
        "arch": "x86_64",
        "requires": [],
        "repo": "alien",
        "package": "libvpx-1.13.1-x86_64-1alien.txz",
    },
    "x264": {
        "version": "20240224",
        "build": "1",
        "arch": "x86_64",
        "requires": ["yasm"],
        "repo": "alien",
        "package": "x264-20240224-x86_64-1alien.txz",
    },
    "yasm": {
        "version": "1.3.0",
        "build": "3",
        "arch": "x86_64",
        "requires": [],
        "repo": "alien",
        "package": "yasm-1.3.0-x86_64-3alien.txz",
    },
    "bash": {
        "version": "5.2.026",
        "build": "1",
        "arch": "x86_64",
        "requires": [],
        "repo": "slack",
        "package": "bash-5.2.026-x86_64-1.txz",
    },
    "perl": {
        "version": "5.38.2",
        "build": "1",
        "arch": "x86_64",
        "requires": [],
        "repo": "alien",
        "package": "perl-5.38.2-x86_64-1alien.txz",
    },
}


@pytest.fixture
def sample_data() -> dict[str, dict[str, str]]:
    """Return a copy of the sample repository data."""
    return {k: dict(v) for k, v in SAMPLE_DATA.items()}


@pytest.fixture
def empty_data() -> dict[str, dict[str, str]]:
    """Return an empty repository data dict."""
    return {}


@pytest.fixture
def dep_data() -> dict[str, dict[str, str]]:
    """Repository data with diamond dependency structure for deduplication tests."""
    return {
        "app": {"version": "1.0", "build": "1", "requires": ["libA", "libB"], "package": "app-1.0-x86_64-1.txz"},
        "libA": {"version": "1.0", "build": "1", "requires": ["shared"], "package": "libA-1.0-x86_64-1.txz"},
        "libB": {"version": "1.0", "build": "1", "requires": ["shared"], "package": "libB-1.0-x86_64-1.txz"},
        "shared": {"version": "1.0", "build": "1", "requires": [], "package": "shared-1.0-x86_64-1.txz"},
    }
