You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.4 KiB
Python
53 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
import asyncio
|
|
from types import SimpleNamespace
|
|
|
|
import app.main as main_module
|
|
|
|
|
|
class _DummyCoreService:
|
|
def available_meeting_intervals(
|
|
self,
|
|
start: str,
|
|
end: str,
|
|
calendar_ids: list[str] | None,
|
|
) -> SimpleNamespace:
|
|
checked = calendar_ids or ["primary"]
|
|
return SimpleNamespace(
|
|
start=start,
|
|
end=end,
|
|
timezone="Europe/Paris",
|
|
meeting_intervals=[
|
|
SimpleNamespace(
|
|
start="2026-03-10T08:30:00+01:00",
|
|
end="2026-03-10T09:30:00+01:00",
|
|
)
|
|
],
|
|
checked_calendars=checked,
|
|
)
|
|
|
|
|
|
def test_rest_meeting_intervals_adapter_returns_expected_payload(monkeypatch) -> None:
|
|
monkeypatch.setattr(main_module, "core_service", _DummyCoreService())
|
|
|
|
response = asyncio.run(
|
|
main_module.meeting_intervals(
|
|
main_module.MeetingIntervalsRequest(
|
|
start="2026-03-10T08:00:00+01:00",
|
|
end="2026-03-10T10:00:00+01:00",
|
|
calendar_ids=["primary"],
|
|
)
|
|
)
|
|
)
|
|
|
|
payload = response.model_dump()
|
|
assert payload["timezone"] == "Europe/Paris"
|
|
assert payload["checked_calendars"] == ["primary"]
|
|
assert payload["meeting_intervals"] == [
|
|
{
|
|
"start": "2026-03-10T08:30:00+01:00",
|
|
"end": "2026-03-10T09:30:00+01:00",
|
|
}
|
|
]
|