from __future__ import annotations

from router.query_classifier import classify_query_for_route


def _store_meta() -> dict:
    return {
        "precomputed_aggregates": ["baseline_period_summary", "period_trend_summary", "risk_slice_summary"],
    }


def test_classifier_heavy_ranking_flags() -> None:
    flags = classify_query_for_route(
        "Рейтинг риск-счетов за июнь",
        {"question_class": "heavy_analytical"},
        _store_meta(),
    )
    assert flags.needs_full_period_aggregation is True
    assert flags.needs_ranking is True
    assert flags.needs_exact_object_trace is False


def test_classifier_drilldown_exact_trace_flags() -> None:
    flags = classify_query_for_route(
        "Цепочка документ -> проводки -> субконто",
        {"question_class": "drilldown_explain"},
        _store_meta(),
    )
    assert flags.needs_exact_object_trace is True
    assert flags.needs_causal_chain is True
    assert flags.needs_runtime_truth is True


def test_classifier_cross_entity_causal_flags() -> None:
    flags = classify_query_for_route(
        "Свяжи контрагентов, договоры и проводки",
        {"question_class": "cross_entity"},
        _store_meta(),
    )
    assert flags.needs_cross_entity_join is True
    assert flags.needs_causal_chain is True
    assert flags.needs_exact_object_trace is False

