from src.aggregator import calculate_priority_score, priority_level
from src.schemas import SentimentResult, RiskResult


def test_priority_score_formula():
    state = {
        "sentiment_result": SentimentResult(
            sentiment="negative",
            frustration_score=8,
            reason="Repeated crashes",
        ),
        "risk_result": RiskResult(
            urgency_score=9,
            churn_risk_score=8,
            churn_signal="Customer threatens to switch",
        ),
    }

    # (90 * .40) + (80 * .35) + (100 * .25) = 89
    assert calculate_priority_score(state) == 89.0
    assert priority_level(89.0) == "CRITICAL"


def test_priority_boundaries():
    assert priority_level(30) == "LOW"
    assert priority_level(31) == "MEDIUM"
    assert priority_level(60) == "MEDIUM"
    assert priority_level(61) == "HIGH"
    assert priority_level(80) == "HIGH"
    assert priority_level(81) == "CRITICAL"
