"""Consent-Historie-Erkennung (#62) — pure Klassifikation."""

from services.consent_history import classify_provider, _is_versioned


def test_classify_borlabs():
    assert classify_provider(["borlabs-cookie", "PHPSESSID"]) == "Borlabs"


def test_classify_onetrust():
    assert classify_provider(["OptanonConsent", "foo"]) == "OneTrust"


def test_classify_cookiebot():
    assert classify_provider(["CookieConsent"]) == "Cookiebot"


def test_classify_unknown_empty():
    assert classify_provider(["sessionid", "csrftoken"]) == ""
    assert classify_provider([]) == ""


def test_versioned_from_stored_value():
    assert _is_versioned("Borlabs", '{"version":3,"consents":{}}') is True
    assert _is_versioned("Borlabs", '{"timestamp":123}') is True


def test_versioned_capability_without_value():
    # Borlabs ist historie-fähig auch ohne ausgelesenen Wert.
    assert _is_versioned("Borlabs", None) is True


def test_not_versioned_unknown_provider():
    assert _is_versioned("", None) is False
    assert _is_versioned("", "irgendwas") is False
