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.
96 lines
2.7 KiB
Python
96 lines
2.7 KiB
Python
from __future__ import annotations
|
|
|
|
import asyncio
|
|
from types import SimpleNamespace
|
|
|
|
from fastapi import Response
|
|
|
|
import app.a2a.router as a2a_module
|
|
from app.a2a.models import A2ARpcRequest
|
|
from app.core.models import CoreMeetingInterval
|
|
import app.main as main_module
|
|
import app.mcp.server as mcp_server_module
|
|
import app.mcp.tools as mcp_tools_module
|
|
|
|
|
|
class _DummyCoreService:
|
|
def available_meeting_intervals(
|
|
self,
|
|
start: str,
|
|
end: str,
|
|
calendar_ids: list[str] | None,
|
|
) -> SimpleNamespace:
|
|
checked = calendar_ids or ["primary"]
|
|
meeting_intervals = [
|
|
CoreMeetingInterval(
|
|
start="2026-03-10T08:30:00+01:00",
|
|
end="2026-03-10T09:30:00+01:00",
|
|
)
|
|
]
|
|
return SimpleNamespace(
|
|
start=start,
|
|
end=end,
|
|
timezone="Europe/Paris",
|
|
meeting_intervals=meeting_intervals,
|
|
checked_calendars=checked,
|
|
)
|
|
|
|
|
|
class _AllowAuthBackend:
|
|
def authenticate(
|
|
self,
|
|
*,
|
|
x_api_key: str | None,
|
|
authorization: str | None,
|
|
required_scopes: set[str],
|
|
) -> None:
|
|
return None
|
|
|
|
|
|
def test_meeting_intervals_parity_rest_a2a_mcp(monkeypatch) -> None:
|
|
dummy_core = _DummyCoreService()
|
|
allow_auth = _AllowAuthBackend()
|
|
|
|
monkeypatch.setattr(main_module, "core_service", dummy_core)
|
|
monkeypatch.setattr(a2a_module, "core_service", dummy_core)
|
|
monkeypatch.setattr(mcp_tools_module, "core_service", dummy_core)
|
|
monkeypatch.setattr(a2a_module, "auth_backend", allow_auth)
|
|
monkeypatch.setattr(mcp_tools_module, "auth_backend", allow_auth)
|
|
|
|
rest_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"],
|
|
)
|
|
)
|
|
).model_dump()
|
|
|
|
a2a_response = a2a_module.a2a_rpc(
|
|
A2ARpcRequest(
|
|
jsonrpc="2.0",
|
|
id="req-1",
|
|
method="SendMessage",
|
|
params={
|
|
"action": "available_meeting_intervals",
|
|
"start": "2026-03-10T08:00:00+01:00",
|
|
"end": "2026-03-10T10:00:00+01:00",
|
|
"calendar_ids": ["primary"],
|
|
},
|
|
),
|
|
Response(),
|
|
)
|
|
assert a2a_response.error is None
|
|
assert a2a_response.result is not None
|
|
a2a_payload = a2a_response.result["meeting_intervals"]
|
|
|
|
mcp_payload = mcp_server_module.available_meeting_intervals(
|
|
start="2026-03-10T08:00:00+01:00",
|
|
end="2026-03-10T10:00:00+01:00",
|
|
calendar_ids=["primary"],
|
|
ctx=None,
|
|
)
|
|
|
|
assert rest_response == a2a_payload == mcp_payload
|