Files
duty-teller/tests/test_import_service.py
Nikolay Tatarinov aa89494bd5
All checks were successful
CI / lint-and-test (push) Successful in 22s
feat: enhance calendar ICS generation with event type filtering
- Added support for filtering calendar events by type in the ICS generation API endpoint, allowing users to specify whether to include only duty shifts or all event types (duty, unavailable, vacation).
- Updated the `get_duties_for_user` function to accept an optional `event_types` parameter, enabling more flexible data retrieval based on user preferences.
- Enhanced unit tests to cover the new event type filtering functionality, ensuring correct behavior and reliability of the ICS generation process.
2026-02-20 17:47:52 +03:00

47 lines
1.4 KiB
Python

"""Tests for duty_teller.services.import_service (_consecutive_date_ranges)."""
from datetime import date
from duty_teller.services.import_service import _consecutive_date_ranges
class TestConsecutiveDateRanges:
"""Unit tests for _consecutive_date_ranges."""
def test_empty_returns_empty(self):
assert _consecutive_date_ranges([]) == []
def test_single_day_one_range(self):
d = date(2025, 2, 10)
assert _consecutive_date_ranges([d]) == [(d, d)]
def test_consecutive_days_one_range(self):
dates = [date(2025, 1, 10), date(2025, 1, 11), date(2025, 1, 12)]
assert _consecutive_date_ranges(dates) == [
(date(2025, 1, 10), date(2025, 1, 12)),
]
def test_two_ranges_with_gap(self):
dates = [
date(2025, 1, 5),
date(2025, 1, 6),
date(2025, 1, 10),
date(2025, 1, 11),
]
assert _consecutive_date_ranges(dates) == [
(date(2025, 1, 5), date(2025, 1, 6)),
(date(2025, 1, 10), date(2025, 1, 11)),
]
def test_unsorted_with_duplicates_normalized(self):
dates = [
date(2025, 1, 12),
date(2025, 1, 10),
date(2025, 1, 11),
date(2025, 1, 10),
]
assert _consecutive_date_ranges(dates) == [
(date(2025, 1, 10), date(2025, 1, 12)),
]