11import asyncio
22import unittest
33import unittest .async_case
4-
54from collections .abc import AsyncGenerator
65from typing import Any , NoReturn
76from unittest .mock import AsyncMock , MagicMock , call , patch
7675)
7776from a2a .utils .errors import ServerError
7877
79-
8078MINIMAL_TASK : dict [str , Any ] = {
8179 'id' : 'task_123' ,
8280 'contextId' : 'session-xyz' ,
@@ -94,7 +92,9 @@ class TestJSONRPCtHandler(unittest.async_case.IsolatedAsyncioTestCase):
9492 @pytest .fixture (autouse = True )
9593 def init_fixtures (self ) -> None :
9694 self .mock_agent_card = MagicMock (
97- spec = AgentCard , url = 'http://agent.example.com/api'
95+ spec = AgentCard ,
96+ url = 'http://agent.example.com/api' ,
97+ supports_authenticated_extended_card = True ,
9898 )
9999
100100 async def test_on_get_task_success (self ) -> None :
@@ -1252,6 +1252,7 @@ async def test_get_authenticated_extended_card_not_configured(self) -> None:
12521252 """Test error when authenticated extended agent card is not configured."""
12531253 # Arrange
12541254 mock_request_handler = AsyncMock (spec = DefaultRequestHandler )
1255+ self .mock_agent_card .supports_extended_card = True
12551256 handler = JSONRPCHandler (
12561257 self .mock_agent_card ,
12571258 mock_request_handler ,
@@ -1267,11 +1268,12 @@ async def test_get_authenticated_extended_card_not_configured(self) -> None:
12671268 )
12681269
12691270 # Assert
1270- self . assertIsInstance ( response . root , JSONRPCErrorResponse )
1271- self . assertEqual ( response . root . id , 'ext- card-req-2' )
1271+ # Authenticated Extended Card flag is set with no extended card,
1272+ # returns base card in this case.
12721273 self .assertIsInstance (
1273- response .root . error , AuthenticatedExtendedCardNotConfiguredError
1274+ response .root , GetAuthenticatedExtendedCardSuccessResponse
12741275 )
1276+ self .assertEqual (response .root .id , 'ext-card-req-2' )
12751277
12761278 async def test_get_authenticated_extended_card_with_modifier (self ) -> None :
12771279 """Test successful retrieval of a dynamically modified extended agent card."""
0 commit comments