"""Core tests for alarmclock module (non-GUI tests)."""

from __future__ import annotations

import pytest

from pytola.office.alarmclock.gui import AlarmClockConfig


class TestAlarmClockConfig:
    """Tests for AlarmClockConfig dataclass."""

    def test_default_config_initialization(self):
        """Test default configuration initialization."""
        config = AlarmClockConfig()

        # Test default values
        assert config.ALARM_CLOCK_TITLE == "Digital Alarm Clock"
        assert config.DIGITAL_FONT == "bold italic 81px 'Consolas'"
        assert config.DIGITAL_COLOR == "#ccee00"
        assert config.DIGITAL_BORDER_COLORS == (
            "#00aa00",
            "#eecc00",
            "#aa00aa",
            "#c0e0b0",
        )
        assert config.DIGITAL_TIMER_FORMAT == "%H:%M:%S"
        assert config.DIGITAL_UPDATE_INTERVAL == 1000
        assert config.BLINK_TITLE == "Alarm Reminder!"
        assert config.BLINK_CONTENT == "⏰ Time's Up!"
        assert config.BLINK_TYPE == "color"
        assert config.BLINK_BG_COLORS == (
            "#baf1ba",
            "#f8ccc3",
            "#aab4f0",
            "#efaec0",
        )
        assert config.BLINK_INTERVAL == 300
        assert config.DELAY_STEPS == (1, 5, 10, 15, 30, 60)

    def test_config_modification(self):
        """Test that configuration can be modified."""
        # Since AlarmClockConfig is frozen, we need to create a new instance
        # with different values, but the current implementation doesn't support this
        # Let's test that we can access all the configuration attributes
        config = AlarmClockConfig()

        # Just verify all attributes exist and have expected types
        assert isinstance(config.ALARM_CLOCK_TITLE, str)
        assert isinstance(config.DIGITAL_FONT, str)
        assert isinstance(config.DIGITAL_COLOR, str)
        assert isinstance(config.DIGITAL_BORDER_COLORS, tuple)
        assert isinstance(config.DIGITAL_TIMER_FORMAT, str)
        assert isinstance(config.DIGITAL_UPDATE_INTERVAL, int)
        assert isinstance(config.BLINK_TITLE, str)
        assert isinstance(config.BLINK_CONTENT, str)
        assert isinstance(config.BLINK_TYPE, str)
        assert isinstance(config.BLINK_BG_COLORS, tuple)
        assert isinstance(config.BLINK_INTERVAL, int)
        assert isinstance(config.DELAY_STEPS, tuple)


class TestAlarmClockFunctionality:
    """Tests for alarm clock core functionality."""

    def test_digital_clock_time_format(self):
        """Test digital clock time formatting."""
        from datetime import datetime, timedelta, timezone

        # Test time formatting
        test_time = datetime.now(timezone.utc) + timedelta(hours=8)
        formatted_time = test_time.strftime("%H:%M:%S")

        # Verify format
        assert len(formatted_time) == 8  # HH:MM:SS
        assert formatted_time[2] == ":"  # Hour-minute separator
        assert formatted_time[5] == ":"  # Minute-second separator

    def test_delay_steps_calculation(self):
        """Test delay steps calculation."""
        config = AlarmClockConfig()

        # Verify delay steps are reasonable
        assert len(config.DELAY_STEPS) == 6
        assert all(isinstance(step, int) for step in config.DELAY_STEPS)
        assert all(step > 0 for step in config.DELAY_STEPS)
        assert config.DELAY_STEPS == (1, 5, 10, 15, 30, 60)

    def test_blink_colors_validation(self):
        """Test blink colors are valid."""
        config = AlarmClockConfig()

        # Verify blink colors are valid hex colors
        for color in config.BLINK_BG_COLORS:
            assert color.startswith("#")
            assert len(color) == 7  # #RRGGBB format
            assert all(c.lower() in "0123456789abcdef" for c in color[1:])

    def test_digital_colors_validation(self):
        """Test digital clock colors are valid."""
        config = AlarmClockConfig()

        # Verify digital colors are valid
        assert config.DIGITAL_COLOR.startswith("#")
        assert len(config.DIGITAL_COLOR) == 7

        for color in config.DIGITAL_BORDER_COLORS:
            assert color.startswith("#")
            assert len(color) == 7


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