from app.tts.performance import PerformanceProfile, EMOTIONS, STYLES

def test_performance_profile_defaults_are_valid():
    profile = PerformanceProfile()
    assert profile.validate() == []
    assert profile.emotion in EMOTIONS
    assert profile.style in STYLES

def test_performance_profile_rejects_invalid_emotion_and_ranges():
    profile = PerformanceProfile(
        emotion="INVALID",
        style="INVALID",
        emotion_intensity=101,
        speaking_rate=2.5,
        pitch_shift=13,
    )
    errors = profile.validate()
    assert "Unsupported emotion: INVALID" in errors
    assert "Unsupported speaking style: INVALID" in errors
    assert "emotion_intensity must be 0-100" in errors
    assert "speaking_rate must be 0.5-2.0" in errors
    assert "pitch_shift must be -12 to 12" in errors

def test_performance_profile_serializes_all_controls():
    profile = PerformanceProfile(
        emotion="ANG",
        emotion_intensity=90,
        dramatic_intensity=85,
        dramatic_pause=40,
        whisper_level=10,
        shout_level=70,
        cry_level=0,
        laugh_level=0,
        breathing_level=25,
        hesitation=5,
        stammer=0,
        voice_break=30,
        voice_fall=80,
        voice_rise=20,
        speaking_rate=0.85,
        pitch_shift=-2,
        style="CIN",
    )
    data = profile.to_dict()
    assert data["emotion"] == "ANG"
    assert data["dramatic_intensity"] == 85
    assert data["dramatic_pause"] == 40
    assert data["voice_break"] == 30
    assert data["speaking_rate"] == 0.85
    assert data["pitch_shift"] == -2
