import pytest

from smw_client import _normalize_mw_category, SmwClientError


def test_normalize_strips_optional_kategorie_prefix():
    assert _normalize_mw_category("Fähigkeitsbeschreibung") == "Fähigkeitsbeschreibung"
    assert _normalize_mw_category(" Kategorie:Fähigkeitsbeschreibung ") == "Fähigkeitsbeschreibung"
    assert _normalize_mw_category("kategorie:test") == "test"


def test_normalize_strips_duplicate_prefix_chain():
    assert _normalize_mw_category("Kategorie:Kategorie:Foo") == "Foo"


def test_normalize_rejects_empty():
    with pytest.raises(SmwClientError, match="leer"):
        _normalize_mw_category("")
    with pytest.raises(SmwClientError, match="leer"):
        _normalize_mw_category("   Kategorie:  ")

