Skip to content

Commit 6b969c8

Browse files
Updated unit tests
1 parent f85f249 commit 6b969c8

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tests/server/request_handlers/test_jsonrpc_handler.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import unittest
22
import unittest.async_case
3-
43
from collections.abc import AsyncGenerator
54
from typing import Any, NoReturn
65
from unittest.mock import AsyncMock, MagicMock, call, patch
@@ -75,7 +74,6 @@
7574
)
7675
from a2a.utils.errors import ServerError
7776

78-
7977
MINIMAL_TASK: dict[str, Any] = {
8078
'id': 'task_123',
8179
'contextId': 'session-xyz',
@@ -93,7 +91,9 @@ class TestJSONRPCtHandler(unittest.async_case.IsolatedAsyncioTestCase):
9391
@pytest.fixture(autouse=True)
9492
def init_fixtures(self) -> None:
9593
self.mock_agent_card = MagicMock(
96-
spec=AgentCard, url='http://agent.example.com/api'
94+
spec=AgentCard,
95+
url='http://agent.example.com/api',
96+
supports_authenticated_extended_card=True,
9797
)
9898

9999
async def test_on_get_task_success(self) -> None:
@@ -1233,6 +1233,7 @@ async def test_get_authenticated_extended_card_not_configured(self) -> None:
12331233
"""Test error when authenticated extended agent card is not configured."""
12341234
# Arrange
12351235
mock_request_handler = AsyncMock(spec=DefaultRequestHandler)
1236+
self.mock_agent_card.supports_extended_card = True
12361237
handler = JSONRPCHandler(
12371238
self.mock_agent_card,
12381239
mock_request_handler,
@@ -1248,11 +1249,12 @@ async def test_get_authenticated_extended_card_not_configured(self) -> None:
12481249
)
12491250

12501251
# Assert
1251-
self.assertIsInstance(response.root, JSONRPCErrorResponse)
1252-
self.assertEqual(response.root.id, 'ext-card-req-2')
1252+
# Authenticated Extended Card flag is set with no extended card,
1253+
# returns base card in this case.
12531254
self.assertIsInstance(
1254-
response.root.error, AuthenticatedExtendedCardNotConfiguredError
1255+
response.root, GetAuthenticatedExtendedCardSuccessResponse
12551256
)
1257+
self.assertEqual(response.root.id, 'ext-card-req-2')
12561258

12571259
async def test_get_authenticated_extended_card_with_modifier(self) -> None:
12581260
"""Test successful retrieval of a dynamically modified extended agent card."""

0 commit comments

Comments
 (0)