"""Tests for time-of-day system."""

from mudlib.timeofday import get_sky_description, get_time_period


def test_get_time_period_dawn():
    assert get_time_period(5) == "dawn"
    assert get_time_period(6) == "dawn"


def test_get_time_period_day():
    assert get_time_period(7) == "day"
    assert get_time_period(12) == "day"
    assert get_time_period(17) == "day"


def test_get_time_period_dusk():
    assert get_time_period(18) == "dusk"
    assert get_time_period(19) == "dusk"


def test_get_time_period_night():
    assert get_time_period(20) == "night"
    assert get_time_period(21) == "night"
    assert get_time_period(23) == "night"
    assert get_time_period(0) == "night"
    assert get_time_period(1) == "night"
    assert get_time_period(4) == "night"


def test_get_sky_description_returns_non_empty():
    for hour in range(24):
        desc = get_sky_description(hour)
        assert desc, f"hour {hour} returned empty description"
        assert isinstance(desc, str)


def test_get_sky_description_differs_by_period():
    dawn_desc = get_sky_description(5)
    day_desc = get_sky_description(12)
    dusk_desc = get_sky_description(18)
    night_desc = get_sky_description(0)

    # each period should have different descriptions
    descriptions = {dawn_desc, day_desc, dusk_desc, night_desc}
    assert len(descriptions) == 4, "periods should have distinct descriptions"


def test_get_sky_description_edge_cases():
    # boundaries between periods
    assert get_sky_description(0)  # night start
    assert get_sky_description(5)  # dawn start
    assert get_sky_description(7)  # day start
    assert get_sky_description(18)  # dusk start
    assert get_sky_description(20)  # night start
    assert get_sky_description(23)  # night end
