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.
simple-agent/tests/test_core_meeting_intervals.py

46 lines
1.4 KiB
Python

from __future__ import annotations
import app.core.service as core_module
from app.config import get_settings
from app.core.service import CoreAgentService
class _FakeFreeBusy:
def __init__(self, payload: dict[str, object]) -> None:
self.payload = payload
def query(self, body: dict[str, object]) -> _FakeFreeBusy:
return self
def execute(self) -> dict[str, object]:
return self.payload
class _FakeCalendarService:
def __init__(self, payload: dict[str, object]) -> None:
self._freebusy = _FakeFreeBusy(payload)
def freebusy(self) -> _FakeFreeBusy:
return self._freebusy
def test_core_meeting_intervals_maps_result(monkeypatch) -> None:
fake_service = _FakeCalendarService({"calendars": {"primary": {"busy": []}}})
monkeypatch.setattr(core_module, "build_calendar_service", lambda _: fake_service)
service = CoreAgentService(settings=get_settings())
result = service.available_meeting_intervals(
start="2026-03-10T08:00:00+01:00",
end="2026-03-10T10:00:00+01:00",
calendar_ids=["primary"],
)
assert result.timezone == "Europe/Paris"
assert result.checked_calendars == ["primary"]
assert result.meeting_intervals == [
core_module.CoreMeetingInterval(
start="2026-03-10T08:30:00+01:00",
end="2026-03-10T10:00:00+01:00",
)
]