790eb6f001
CI / benchmark-publish (pull_request) Has been skipped
CI / push-validation (pull_request) Successful in 25s
CI / helm (pull_request) Successful in 31s
CI / build (pull_request) Successful in 53s
CI / lint (pull_request) Successful in 1m5s
CI / typecheck (pull_request) Successful in 1m24s
CI / security (pull_request) Successful in 1m53s
CI / quality (pull_request) Successful in 1m54s
CI / integration_tests (pull_request) Successful in 3m40s
CI / e2e_tests (pull_request) Successful in 4m28s
CI / unit_tests (pull_request) Successful in 5m6s
CI / docker (pull_request) Successful in 1m30s
CI / coverage (pull_request) Successful in 10m50s
CI / status-check (pull_request) Successful in 3s
CI / helm (push) Successful in 31s
CI / build (push) Successful in 52s
CI / lint (push) Successful in 1m1s
CI / typecheck (push) Successful in 1m26s
CI / quality (push) Successful in 1m26s
CI / security (push) Successful in 1m42s
CI / push-validation (push) Successful in 22s
CI / benchmark-publish (push) Failing after 43s
CI / integration_tests (push) Failing after 3m39s
CI / e2e_tests (push) Successful in 4m23s
CI / unit_tests (push) Successful in 4m38s
CI / docker (push) Successful in 1m38s
CI / coverage (push) Successful in 10m50s
CI / status-check (push) Failing after 3s
- Added Faker dependency to pyproject.toml for dynamic test data generation - Created features/test_data_factory.py with TestDataGenerator and ContextFragmentFactory classes for Behave tests - Created robot/helper_test_data_factory.py with RobotTestDataGenerator and factory classes for Robot Framework tests - Created features/test_data_loader.py to load externalized test data from JSON files - Created features/fixtures/test_data_samples.json with realistic test data samples - Updated robot/helper_acms_fusion.py to use dynamic test data generation instead of hardcoded values like "alpha" and "beta" - All quality gates passing: lint, typecheck, unit tests, integration tests, coverage ≥ 97% ISSUES CLOSED: #9048
93 lines
3.0 KiB
Python
93 lines
3.0 KiB
Python
"""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()
|