Skip to content

Commit b6247b6

Browse files
committed
add tests
1 parent 085980f commit b6247b6

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

tests/compat/v0_3/test_jsonrpc_app_compat.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,25 @@ def test_get_task_v03_compat(
111111
assert 'result' in data
112112
assert data['result']['id'] == 'test_task_id'
113113
assert data['result']['status']['state'] == 'completed'
114+
115+
116+
def test_get_extended_agent_card_v03_compat(
117+
client: TestClient,
118+
) -> None:
119+
"""Test that the v0.3 method name 'agent/getAuthenticatedExtendedCard' is correctly routed."""
120+
request_payload = {
121+
'jsonrpc': '2.0',
122+
'id': '3',
123+
'method': 'agent/getAuthenticatedExtendedCard',
124+
'params': {},
125+
}
126+
127+
response = client.post('/', json=request_payload)
128+
assert response.status_code == 200
129+
data = response.json()
130+
131+
assert data['jsonrpc'] == '2.0'
132+
assert data['id'] == '3'
133+
assert 'result' in data
134+
# The result should be a v0.3 AgentCard
135+
assert 'supportsAuthenticatedExtendedCard' in data['result']

tests/compat/v0_3/test_jsonrpc_transport.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,35 @@ async def test_compat_jsonrpc_transport_get_extended_agent_card_not_supported(
348348
assert response == transport.agent_card
349349

350350

351+
@pytest.mark.asyncio
352+
async def test_compat_jsonrpc_transport_get_extended_agent_card_method_name(
353+
transport,
354+
):
355+
"""Verify the correct v0.3 method name 'agent/getAuthenticatedExtendedCard' is used."""
356+
captured_request: dict | None = None
357+
358+
async def mock_send_request(data, *args, **kwargs):
359+
nonlocal captured_request
360+
captured_request = data
361+
return {
362+
'result': {
363+
'name': 'ExtendedAgent',
364+
'url': 'http://agent',
365+
'version': '1.0.0',
366+
'capabilities': {},
367+
'supportsAuthenticatedExtendedCard': True,
368+
}
369+
}
370+
371+
transport._send_request = mock_send_request
372+
373+
req = GetExtendedAgentCardRequest()
374+
await transport.get_extended_agent_card(req)
375+
376+
assert captured_request is not None
377+
assert captured_request['method'] == 'agent/getAuthenticatedExtendedCard'
378+
379+
351380
@pytest.mark.asyncio
352381
async def test_compat_jsonrpc_transport_close(transport, mock_httpx_client):
353382
await transport.close()

0 commit comments

Comments
 (0)