feat: add team calendar ICS endpoint and related functionality
All checks were successful
CI / lint-and-test (push) Successful in 23s
All checks were successful
CI / lint-and-test (push) Successful in 23s
- Implemented a new API endpoint to generate an ICS calendar for team duty shifts, accessible via a valid token. - Enhanced the `calendar_link` command to return both personal and team calendar URLs. - Added a new function to build the team ICS file, ensuring each event includes the duty holder's name in the description. - Updated tests to cover the new team calendar functionality, including validation for token formats and response content. - Revised internationalization messages to reflect the new team calendar links.
This commit is contained in:
@@ -202,7 +202,7 @@ async def test_set_phone_result_error_replies_error():
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_calendar_link_with_user_and_token_replies_with_url():
|
||||
"""calendar_link with allowed user and token -> reply with link."""
|
||||
"""calendar_link with allowed user and token -> reply with personal and team URLs."""
|
||||
message = MagicMock()
|
||||
message.reply_text = AsyncMock()
|
||||
user = _make_user()
|
||||
@@ -233,14 +233,15 @@ async def test_calendar_link_with_user_and_token_replies_with_url():
|
||||
):
|
||||
with patch("duty_teller.handlers.commands.t") as mock_t:
|
||||
mock_t.side_effect = lambda lang, key, **kw: (
|
||||
f"URL: {kw.get('url', '')}"
|
||||
f"Personal: {kw.get('url_personal', '')} Team: {kw.get('url_team', '')}"
|
||||
if "success" in key
|
||||
else "Hint"
|
||||
)
|
||||
await calendar_link(update, MagicMock())
|
||||
message.reply_text.assert_called_once()
|
||||
call_args = message.reply_text.call_args[0][0]
|
||||
assert "abc43token" in call_args or "example.com" in call_args
|
||||
assert "/api/calendar/ical/abc43token.ics" in call_args
|
||||
assert "/api/calendar/ical/team/abc43token.ics" in call_args
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user