import pytest

from tests.unit_tests.rag.intent_router_testkit import run_sequence

pytestmark = pytest.mark.intent_router


@pytest.mark.parametrize(
    ("query", "plan_id", "primary_doc_types", "secondary_doc_types", "expected_filter_key", "expected_filter_value"),
    [
        ("объясни /health", "docs_api_method_explain_v1", ["api_method"], ["logic_block", "domain_entity", "architecture_overview"], "endpoint_path", "/health"),
        ("какие методы в notifications", "docs_list_api_methods_v1", ["api_method"], [], "domain_name", "notifications"),
        ("найди документацию по telegram_delivery", "docs_find_documents_by_domain_v1", ["index_page", "architecture_overview", "api_method", "logic_block", "domain_entity"], [], "domain_name", "telegram_delivery"),
        ("сгенерируй openapi по /send", "docs_generate_openapi_v1", ["api_method"], ["domain_entity", "logic_block"], "endpoint_path", "/send"),
        ("как устроен сервис", "docs_general_docs_qa_v1", ["index_page", "architecture_overview"], ["logic_block", "domain_entity", "api_method"], "scope_level", "project"),
    ],
)
def test_docs_retrieval_plan_contracts(
    query: str,
    plan_id: str,
    primary_doc_types: list[str],
    secondary_doc_types: list[str],
    expected_filter_key: str,
    expected_filter_value: str,
) -> None:
    result = run_sequence([query])[0]

    assert result.retrieval_plan is not None
    assert result.retrieval_plan.plan_id == plan_id
    assert result.retrieval_plan.primary_doc_types == primary_doc_types
    assert result.retrieval_plan.secondary_doc_types == secondary_doc_types
    assert result.retrieval_plan.filters[expected_filter_key] == expected_filter_value
