feat: enhance calendar ICS generation with event type filtering
All checks were successful
CI / lint-and-test (push) Successful in 22s
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:
@@ -1,6 +1,6 @@
|
||||
"""Tests for duty_teller.services.group_duty_pin_service."""
|
||||
|
||||
from datetime import datetime, timezone
|
||||
from datetime import datetime
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import patch
|
||||
|
||||
@@ -8,7 +8,7 @@ import pytest
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
from duty_teller.db.models import Base, Duty, GroupDutyPin, User
|
||||
from duty_teller.db.models import Base, Duty, User
|
||||
from duty_teller.services import group_duty_pin_service as svc
|
||||
|
||||
|
||||
@@ -72,7 +72,9 @@ class TestFormatDutyMessage:
|
||||
mock_t.assert_called_with("en", "duty.no_duty")
|
||||
|
||||
def test_none_user_returns_no_duty(self):
|
||||
duty = SimpleNamespace(start_at="2025-01-15T09:00:00Z", end_at="2025-01-15T18:00:00Z")
|
||||
duty = SimpleNamespace(
|
||||
start_at="2025-01-15T09:00:00Z", end_at="2025-01-15T18:00:00Z"
|
||||
)
|
||||
with patch("duty_teller.services.group_duty_pin_service.t") as mock_t:
|
||||
mock_t.return_value = "No duty"
|
||||
result = svc.format_duty_message(duty, None, "Europe/Moscow", "en")
|
||||
@@ -89,9 +91,7 @@ class TestFormatDutyMessage:
|
||||
username="ivan",
|
||||
)
|
||||
with patch("duty_teller.services.group_duty_pin_service.t") as mock_t:
|
||||
mock_t.side_effect = lambda lang, key: (
|
||||
"Duty" if key == "duty.label" else ""
|
||||
)
|
||||
mock_t.side_effect = lambda lang, key: "Duty" if key == "duty.label" else ""
|
||||
result = svc.format_duty_message(duty, user, "Europe/Moscow", "ru")
|
||||
assert "Иван Иванов" in result
|
||||
assert "+79001234567" in result or "79001234567" in result
|
||||
|
||||
Reference in New Issue
Block a user