feat: enhance calendar ICS generation with event type filtering
All checks were successful
CI / lint-and-test (push) Successful in 22s

- 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.
This commit is contained in:
2026-02-20 17:47:52 +03:00
parent e25eb7be2f
commit aa89494bd5
12 changed files with 160 additions and 30 deletions

View File

@@ -106,7 +106,9 @@ class TestGetEventsFromIcs:
assert result == []
def test_broken_ics_returns_empty_list(self):
result = mod._get_events_from_ics(b"not ical at all", "2025-01-01", "2025-01-31")
result = mod._get_events_from_ics(
b"not ical at all", "2025-01-01", "2025-01-31"
)
assert result == []
def test_recurring_events_skipped(self):
@@ -128,11 +130,18 @@ class TestGetCalendarEvents:
assert mod.get_calendar_events("", "2025-01-01", "2025-01-31") == []
def test_from_after_to_returns_empty(self):
assert mod.get_calendar_events("https://example.com/a.ics", "2025-02-01", "2025-01-01") == []
assert (
mod.get_calendar_events(
"https://example.com/a.ics", "2025-02-01", "2025-01-01"
)
== []
)
@patch.object(mod, "_fetch_ics", return_value=None)
def test_fetch_returns_none_returns_empty(self, mock_fetch):
result = mod.get_calendar_events("https://example.com/a.ics", "2025-01-01", "2025-01-31")
result = mod.get_calendar_events(
"https://example.com/a.ics", "2025-01-01", "2025-01-31"
)
assert result == []
mock_fetch.assert_called_once()