Files

28 lines
935 B
Python
Raw Permalink Normal View History

"""Tests for the shared metric registry factory."""
from unittest.mock import MagicMock
from ragas.llms.base import InstructorBaseRagasLLM
from ragas.embeddings.base import BaseRagasEmbedding
from rag_eval.metrics.factory import build_metric_registry
def _mock_llm():
"""Return a mock that passes RAGAS InstructorLLM type checks."""
return MagicMock(spec=InstructorBaseRagasLLM)
def _mock_emb():
"""Return a mock that passes RAGAS embedding type checks."""
return MagicMock(spec=BaseRagasEmbedding)
def test_build_metric_registry_has_all_seven_metrics():
"""The registry exposes every supported metric keyed by its canonical name."""
registry = build_metric_registry(llm=_mock_llm(), embeddings=_mock_emb())
assert set(registry) == {
"faithfulness", "answer_relevancy", "context_recall", "context_precision",
"noise_sensitivity", "factual_correctness", "semantic_similarity",
}