"""Loader for externalized test data from JSON files.

This module provides utilities to load and access test data that has been
externalized to JSON files for easier management and reuse across multiple
test scenarios.

Usage:
    from features.test_data_loader import TestDataLoader

    loader = TestDataLoader()
    project_names = loader.get_project_names()
    skill_names = loader.get_skill_names()
    python_samples = loader.get_python_code_samples()
"""

from __future__ import annotations

import json
from pathlib import Path
from typing import Any


class TestDataLoader:
    """Load and provide access to externalized test data."""

    _DATA_FILE = Path(__file__).parent / "fixtures" / "test_data_samples.json"
    _cache: dict[str, Any] | None = None

    @classmethod
    def _load_data(cls) -> dict[str, Any]:
        """Load test data from JSON file (cached)."""
        if cls._cache is None:
            if not cls._DATA_FILE.exists():
                raise FileNotFoundError(f"Test data file not found: {cls._DATA_FILE}")
            with open(cls._DATA_FILE) as f:
                cls._cache = json.load(f)
        return cls._cache

    @classmethod
    def get_project_names(cls) -> list[str]:
        """Get list of realistic project names."""
        return cls._load_data().get("project_names", [])

    @classmethod
    def get_skill_names(cls) -> list[str]:
        """Get list of realistic skill names."""
        return cls._load_data().get("skill_names", [])

    @classmethod
    def get_tool_names(cls) -> list[str]:
        """Get list of realistic tool names."""
        return cls._load_data().get("tool_names", [])

    @classmethod
    def get_python_code_samples(cls) -> list[str]:
        """Get list of realistic Python code samples."""
        return cls._load_data().get("python_code_samples", [])

    @classmethod
    def get_file_paths(cls) -> list[str]:
        """Get list of realistic file paths."""
        return cls._load_data().get("file_paths", [])

    @classmethod
    def get_uko_node_uris(cls) -> list[str]:
        """Get list of realistic UKO node URIs."""
        return cls._load_data().get("uko_node_uris", [])

    @classmethod
    def get_resource_uris(cls) -> list[str]:
        """Get list of realistic resource URIs."""
        return cls._load_data().get("resource_uris", [])

    @classmethod
    def get_prose_samples(cls) -> list[str]:
        """Get list of realistic prose samples."""
        return cls._load_data().get("prose_samples", [])

    @classmethod
    def get_edge_case_names(cls) -> list[str]:
        """Get list of edge case names for boundary testing."""
        return cls._load_data().get("edge_case_names", [])

    @classmethod
    def get_invalid_special_chars(cls) -> list[str]:
        """Get list of invalid special characters for validation testing."""
        return cls._load_data().get("invalid_special_chars", [])

    @classmethod
    def get_all_data(cls) -> dict[str, Any]:
        """Get all loaded test data."""
        return cls._load_data()
