from rights_filter.analysis.search_result_promoter import SearchResultPromoter
from rights_filter.domain.records import Evidence, EvidenceSource


def test_promotes_named_person_or_work_naver_result():
    evidence = Evidence(
        source=EvidenceSource.NAVER_SEARCH,
        reason="Naver search result found",
        confidence=0.5,
        data={
            "title": "IU official album cover",
            "query": "IU album cover",
            "result_url": "https://official.example.test/iu",
        },
    )

    promoted = SearchResultPromoter().promote([evidence])[0]

    assert promoted.data["promoted"] is True
    assert promoted.data["promotion_reason"] == "named person/work search evidence"
    assert promoted.confidence == 0.8


def test_generic_naver_result_remains_context_only():
    evidence = Evidence(
        source=EvidenceSource.NAVER_SEARCH,
        reason="Naver search result found",
        confidence=0.5,
        data={
            "title": "nice drawing",
            "query": "nice drawing",
            "result_url": "https://example.test/drawing",
        },
    )

    promoted = SearchResultPromoter().promote([evidence])[0]

    assert promoted.data["promoted"] is False
    assert promoted.confidence == 0.2
