"""Tests for confidence → status mapping."""

from agent_samochodowy.config import Settings
from agent_samochodowy.models import MatchResult
from agent_samochodowy.status import map_status


def _settings(high: float = 0.85, low: float = 0.50) -> Settings:
    return Settings(confidence_high=high, confidence_low=low)


class TestMapStatus:
    def test_high_confidence(self):
        r = MatchResult(confidence=0.95, method="oe", matched=True)
        assert map_status(r, _settings()) == "Dopasowano"

    def test_exactly_high_threshold(self):
        r = MatchResult(confidence=0.85, method="engine_code", matched=True)
        assert map_status(r, _settings()) == "Dopasowano"

    def test_medium_confidence(self):
        r = MatchResult(confidence=0.65, method="atrybuty", matched=True)
        assert map_status(r, _settings()) == "Do weryfikacji"

    def test_exactly_low_threshold(self):
        r = MatchResult(confidence=0.50, method="fuzzy", matched=True)
        assert map_status(r, _settings()) == "Do weryfikacji"

    def test_below_low_threshold(self):
        r = MatchResult(confidence=0.49, method="fuzzy", matched=True)
        assert map_status(r, _settings()) == "Brak dopasowania"

    def test_no_match(self):
        r = MatchResult(confidence=0.0, method="brak", matched=False)
        assert map_status(r, _settings()) == "Brak dopasowania"

    def test_custom_thresholds(self):
        r = MatchResult(confidence=0.70, method="atrybuty", matched=True)
        assert map_status(r, _settings(high=0.90, low=0.70)) == "Do weryfikacji"
        assert map_status(r, _settings(high=0.70, low=0.50)) == "Dopasowano"
