Increases overall test coverage from 53% to 56% by adding tests for: - accommodation.py (60% → 100%) - birthday.py (24% → 100%) - calendar.py (19% → 100%) - carnival.py (33% → 100%) - domains.py (75% → 100%) - events_yaml.py (50% → 96%) - fx.py (14% → 21% for tested functions) - sun.py (55% → 100%) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
"""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 |