11import unittest
22import unittest .async_case
3-
43from collections .abc import AsyncGenerator
54from typing import Any , NoReturn
65from unittest .mock import AsyncMock , MagicMock , call , patch
7574)
7675from a2a .utils .errors import ServerError
7776
78-
7977MINIMAL_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 :
@@ -1235,6 +1235,7 @@ async def test_get_authenticated_extended_card_not_configured(self) -> None:
12351235 """Test error when authenticated extended agent card is not configured."""
12361236 # Arrange
12371237 mock_request_handler = AsyncMock (spec = DefaultRequestHandler )
1238+ self .mock_agent_card .supports_extended_card = True
12381239 handler = JSONRPCHandler (
12391240 self .mock_agent_card ,
12401241 mock_request_handler ,
@@ -1250,11 +1251,12 @@ async def test_get_authenticated_extended_card_not_configured(self) -> None:
12501251 )
12511252
12521253 # Assert
1253- self . assertIsInstance ( response . root , JSONRPCErrorResponse )
1254- self . assertEqual ( response . root . id , 'ext- card-req-2' )
1254+ # Authenticated Extended Card flag is set with no extended card,
1255+ # returns base card in this case.
12551256 self .assertIsInstance (
1256- response .root . error , AuthenticatedExtendedCardNotConfiguredError
1257+ response .root , GetAuthenticatedExtendedCardSuccessResponse
12571258 )
1259+ self .assertEqual (response .root .id , 'ext-card-req-2' )
12581260
12591261 async def test_get_authenticated_extended_card_with_modifier (self ) -> None :
12601262 """Test successful retrieval of a dynamically modified extended agent card."""
0 commit comments