"""Tests for events_yaml functionality.""" from datetime import date, datetime, time from agenda.events_yaml import midnight class TestMidnight: """Test the midnight function.""" def test_midnight_with_date(self) -> None: """Test converting date to midnight datetime.""" test_date = date(2024, 6, 15) result = midnight(test_date) assert isinstance(result, datetime) assert result.date() == test_date assert result.time() == time(0, 0, 0) # Midnight assert result == datetime(2024, 6, 15, 0, 0, 0) def test_midnight_different_dates(self) -> None: """Test midnight function with different dates.""" test_cases = [ date(2024, 1, 1), # New Year's Day date(2024, 12, 31), # New Year's Eve date(2024, 2, 29), # Leap day date(2024, 7, 4), # Independence Day ] for test_date in test_cases: result = midnight(test_date) assert result.date() == test_date assert result.time() == time(0, 0, 0) assert result.hour == 0 assert result.minute == 0 assert result.second == 0 assert result.microsecond == 0 def test_midnight_preserves_year_month_day(self) -> None: """Test that midnight preserves the year, month, and day.""" test_date = date(2023, 11, 27) result = midnight(test_date) assert result.year == 2023 assert result.month == 11 assert result.day == 27 assert result.hour == 0 assert result.minute == 0 assert result.second == 0