Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/a2a/client/transports/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from a2a.client.transports.base import ClientTransport
from a2a.client.transports.jsonrpc import JsonRpcTransport
from a2a.client.transports.rest import RestTransport
from a2a.client.transports.tenant_decorator import TenantTransportDecorator


try:
Expand All @@ -16,4 +17,5 @@
'GrpcTransport',
'JsonRpcTransport',
'RestTransport',
'TenantTransportDecorator',
]
2 changes: 1 addition & 1 deletion src/a2a/client/transports/tenant_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async def send_message(
*,
context: ClientCallContext | None = None,
) -> SendMessageResponse:
"""Sends a streaming message request to the agent and yields responses as they arrive."""
"""Sends a non-streaming message request to the agent."""
request.tenant = self._resolve_tenant(request.tenant)
return await self._base.send_message(request, context=context)

Expand Down
19 changes: 19 additions & 0 deletions tests/client/transports/test_tenant_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,22 @@ async def mock_stream(*args, **kwargs):
async for _ in decorator.send_message_streaming(request_msg):
pass
assert request_msg.tenant == tenant_id

@pytest.mark.asyncio
async def test_close_delegates_to_base(
self, mock_transport: AsyncMock
) -> None:
"""Test that close() is delegated to the underlying transport."""
decorator = TenantTransportDecorator(mock_transport, 'test-tenant')
await decorator.close()
mock_transport.close.assert_awaited_once()

@pytest.mark.asyncio
async def test_async_context_manager(
self, mock_transport: AsyncMock
) -> None:
"""Test that the decorator works as an async context manager."""
decorator = TenantTransportDecorator(mock_transport, 'test-tenant')
async with decorator as transport:
assert transport is decorator
mock_transport.close.assert_awaited_once()
Loading