feat: add tests for admin checks and error handling
All checks were successful
CI / lint-and-test (push) Successful in 23s

- Introduced new tests for the `is_admin_async` function to verify correct behavior based on user roles.
- Added tests for error handling in the `error_handler` to ensure exceptions are logged and do not propagate.
- Enhanced test coverage for configuration settings by adding a test for parsing admin phone numbers from environment variables.
- Updated the `.cursorrules` file to include the use of a virtual environment for better dependency management.
This commit is contained in:
2026-02-21 00:50:29 +03:00
parent bf8ac87a73
commit 35946a5812
6 changed files with 99 additions and 0 deletions

View File

@@ -58,3 +58,19 @@ def test_build_personal_ics_event_types():
summaries = [str(ev.get("summary")) for ev in events]
assert "Unavailable" in summaries
assert "Vacation" in summaries
def test_build_personal_ics_naive_datetime_treated_as_utc():
"""Duties with start_at/end_at without Z (naive datetime) are treated as UTC."""
duties = [
_duty(1, "2025-02-20T09:00:00", "2025-02-20T18:00:00", "duty"),
]
ics = build_personal_ics(duties)
cal = ICalendar.from_ical(ics)
assert cal is not None
events = [c for c in cal.walk() if c.name == "VEVENT"]
assert len(events) == 1
ev = events[0]
assert ev.get("summary") == "Duty"
assert "2025-02-20" in str(ev.get("dtstart").dt)
assert "2025-02-20" in str(ev.get("dtend").dt)