import pytest

from veena3modal.processing.emotion_normalizer import (
    normalize_emotion_tags,
    validate_normalized_text,
)


def test_normalize_emotion_tags_angle_to_bracket_and_common_variants():
    text = "Hello <laugh> and <laugh_harder> then [giggles] and [Whisper]."
    out = normalize_emotion_tags(text)

    # Angle tags must be removed.
    assert "<" not in out and ">" not in out

    # Canonical Spark TTS bracket tags.
    assert "[laughs]" in out
    assert "[laughs harder]" in out
    assert "[giggle]" in out
    assert "[whispers]" in out


def test_normalize_emotion_tags_unknown_angle_is_converted_to_brackets():
    assert normalize_emotion_tags("Hello <mystery>.") == "Hello [mystery]."


def test_validate_normalized_text_reports_angle_brackets_as_invalid():
    v = validate_normalized_text("Hello <laugh>.")
    assert v["has_angle_brackets"] is True
    assert v["is_valid"] is False


def test_validate_normalized_text_accepts_bracket_only():
    v = validate_normalized_text("Hello [laughs].")
    assert v["has_angle_brackets"] is False
    assert v["is_valid"] is True


