Add comprehensive test coverage for 8 modules
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>
This commit is contained in:
parent
8db777ae8b
commit
e6327780aa
8 changed files with 1390 additions and 0 deletions
49
tests/test_events_yaml.py
Normal file
49
tests/test_events_yaml.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
"""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
|
||||
Loading…
Add table
Add a link
Reference in a new issue