@@ -69,6 +69,7 @@ def transport(mock_httpx_client, agent_card):
6969 """Creates a JsonRpcTransport instance for testing."""
7070 return JsonRpcTransport (
7171 httpx_client = mock_httpx_client ,
72+ url = 'http://test-agent.example.com' ,
7273 agent_card = agent_card ,
7374 )
7475
@@ -79,6 +80,7 @@ def transport_with_url(mock_httpx_client):
7980 return JsonRpcTransport (
8081 httpx_client = mock_httpx_client ,
8182 url = 'http://custom-url.example.com' ,
83+ agent_card = AgentCard (name = 'Dummy' ),
8284 )
8385
8486
@@ -112,41 +114,20 @@ def test_init_with_agent_card(self, mock_httpx_client, agent_card):
112114 """Test initialization with an agent card."""
113115 transport = JsonRpcTransport (
114116 httpx_client = mock_httpx_client ,
117+ url = 'http://test-agent.example.com' ,
115118 agent_card = agent_card ,
116119 )
117120 assert transport .url == 'http://test-agent.example.com'
118121 assert transport .agent_card == agent_card
119122
120- def test_init_with_url (self , mock_httpx_client ):
121- """Test initialization with a URL."""
122- transport = JsonRpcTransport (
123- httpx_client = mock_httpx_client ,
124- url = 'http://custom-url.example.com' ,
125- )
126- assert transport .url == 'http://custom-url.example.com'
127- assert transport .agent_card is None
128-
129- def test_init_url_takes_precedence (self , mock_httpx_client , agent_card ):
130- """Test that explicit URL takes precedence over agent card URL."""
131- transport = JsonRpcTransport (
132- httpx_client = mock_httpx_client ,
133- agent_card = agent_card ,
134- url = 'http://override-url.example.com' ,
135- )
136- assert transport .url == 'http://override-url.example.com'
137123
138- def test_init_requires_url_or_agent_card (self , mock_httpx_client ):
139- """Test that initialization requires either URL or agent card."""
140- with pytest .raises (
141- ValueError , match = 'Must provide either agent_card or url'
142- ):
143- JsonRpcTransport (httpx_client = mock_httpx_client )
144124
145125 def test_init_with_interceptors (self , mock_httpx_client , agent_card ):
146126 """Test initialization with interceptors."""
147127 interceptor = MagicMock ()
148128 transport = JsonRpcTransport (
149129 httpx_client = mock_httpx_client ,
130+ url = 'http://test-agent.example.com' ,
150131 agent_card = agent_card ,
151132 interceptors = [interceptor ],
152133 )
@@ -157,6 +138,7 @@ def test_init_with_extensions(self, mock_httpx_client, agent_card):
157138 extensions = ['https://example.com/ext1' , 'https://example.com/ext2' ]
158139 transport = JsonRpcTransport (
159140 httpx_client = mock_httpx_client ,
141+ url = 'http://test-agent.example.com' ,
160142 agent_card = agent_card ,
161143 extensions = extensions ,
162144 )
@@ -465,6 +447,7 @@ async def test_interceptor_called(self, mock_httpx_client, agent_card):
465447
466448 transport = JsonRpcTransport (
467449 httpx_client = mock_httpx_client ,
450+ url = 'http://test-agent.example.com' ,
468451 agent_card = agent_card ,
469452 interceptors = [interceptor ],
470453 )
@@ -504,6 +487,7 @@ async def test_extensions_added_to_request(
504487 extensions = ['https://example.com/ext1' ]
505488 transport = JsonRpcTransport (
506489 httpx_client = mock_httpx_client ,
490+ url = 'http://test-agent.example.com' ,
507491 agent_card = agent_card ,
508492 extensions = extensions ,
509493 )
@@ -547,6 +531,7 @@ async def test_send_message_streaming_server_error_propagates(
547531 """Test that send_message_streaming propagates server errors (e.g., 403, 500) directly."""
548532 client = JsonRpcTransport (
549533 httpx_client = mock_httpx_client ,
534+ url = 'http://test-agent.example.com' ,
550535 agent_card = agent_card ,
551536 )
552537 request = create_send_message_request (text = 'Error stream' )
@@ -577,40 +562,7 @@ async def empty_aiter():
577562 assert exc_info .value .status_code == 403
578563 mock_aconnect_sse .assert_called_once ()
579564
580- @pytest .mark .asyncio
581- async def test_get_card_no_card_provided_with_extensions (
582- self , mock_httpx_client : AsyncMock , agent_card : AgentCard
583- ):
584- """Test get_extended_agent_card with extensions set in Client when no card is initially provided.
585- Tests that the extensions are added to the HTTP GET request."""
586- extensions = [
587- 'https://example.com/test-ext/v1' ,
588- 'https://example.com/test-ext/v2' ,
589- ]
590- client = JsonRpcTransport (
591- httpx_client = mock_httpx_client ,
592- url = 'http://test-agent.example.com' ,
593- extensions = extensions ,
594- )
595- mock_response = AsyncMock (spec = httpx .Response )
596- mock_response .status_code = 200
597- mock_response .json .return_value = json_format .MessageToDict (agent_card )
598- mock_httpx_client .get .return_value = mock_response
599-
600- agent_card .capabilities .extended_agent_card = False
601-
602- await client .get_extended_agent_card ()
603565
604- mock_httpx_client .get .assert_called_once ()
605- _ , mock_kwargs = mock_httpx_client .get .call_args
606-
607- _assert_extensions_header (
608- mock_kwargs ,
609- {
610- 'https://example.com/test-ext/v1' ,
611- 'https://example.com/test-ext/v2' ,
612- },
613- )
614566
615567 @pytest .mark .asyncio
616568 async def test_get_card_with_extended_card_support_with_extensions (
@@ -626,6 +578,7 @@ async def test_get_card_with_extended_card_support_with_extensions(
626578
627579 client = JsonRpcTransport (
628580 httpx_client = mock_httpx_client ,
581+ url = 'http://test-agent.example.com' ,
629582 agent_card = agent_card ,
630583 extensions = extensions ,
631584 )
0 commit comments