from __future__ import annotations

from pathlib import Path

from tests.pipeline_setup.suite_02_pipeline.pipeline_intent_rag.helpers.phrases_loader import PhraseCatalogLoader


def test_phrase_catalog_has_cases_and_unique_ids() -> None:
    path = Path(__file__).resolve().parent / "fixtures" / "phrases.yaml"
    cases = PhraseCatalogLoader().load(path)

    assert len(cases) >= 5
    case_ids = [item.case_id for item in cases]
    assert len(case_ids) == len(set(case_ids))
    assert all(item.text for item in cases)


def test_phrase_catalog_has_tags_for_all_iterations() -> None:
    path = Path(__file__).resolve().parent / "fixtures" / "phrases.yaml"
    loader = PhraseCatalogLoader()
    cases = loader.load(path)

    assert loader.filter_by_tag(cases, "router_only")
    assert loader.filter_by_tag(cases, "router_rag")
    assert loader.filter_by_tag(cases, "full_chain")
