"""
test_tts_personality.py — Tests for TTS personality engine
"""

import pytest
from saltybot_tts_personality.tts_personality_node import PersonalityContext
from datetime import datetime


def test_personality_context_emotion():
    """Test emotion state management."""
    context = PersonalityContext()
    assert context.current_emotion == "neutral"

    context.update_emotion("happy")
    assert context.current_emotion == "happy"

    context.update_emotion("sad")
    assert context.current_emotion == "sad"


def test_personality_context_person():
    """Test person tracking."""
    context = PersonalityContext()
    assert context.last_person is None

    context.update_person("Alice")
    assert context.last_person == "Alice"

    context.update_person("Bob")
    assert context.last_person == "Bob"


def test_time_period_classification():
    """Test time period classification."""
    context = PersonalityContext()

    # These tests depend on current time, so we just verify the function works
    period = context.get_time_period()
    assert period in ["morning", "afternoon", "evening", "night"]


def test_personality_context_timestamps():
    """Test timestamp tracking for context validity."""
    context = PersonalityContext()
    import time

    ts_before = context.emotion_timestamp
    time.sleep(0.01)
    context.update_emotion("happy")
    ts_after = context.emotion_timestamp

    assert ts_after > ts_before


if __name__ == "__main__":
    pytest.main([__file__, "-v"])
