@@ -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,18 @@ 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'
137-
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 )
144-
145123 def test_init_with_interceptors (self , mock_httpx_client , agent_card ):
146124 """Test initialization with interceptors."""
147125 interceptor = MagicMock ()
148126 transport = JsonRpcTransport (
149127 httpx_client = mock_httpx_client ,
128+ url = 'http://test-agent.example.com' ,
150129 agent_card = agent_card ,
151130 interceptors = [interceptor ],
152131 )
@@ -157,6 +136,7 @@ def test_init_with_extensions(self, mock_httpx_client, agent_card):
157136 extensions = ['https://example.com/ext1' , 'https://example.com/ext2' ]
158137 transport = JsonRpcTransport (
159138 httpx_client = mock_httpx_client ,
139+ url = 'http://test-agent.example.com' ,
160140 agent_card = agent_card ,
161141 extensions = extensions ,
162142 )
@@ -465,6 +445,7 @@ async def test_interceptor_called(self, mock_httpx_client, agent_card):
465445
466446 transport = JsonRpcTransport (
467447 httpx_client = mock_httpx_client ,
448+ url = 'http://test-agent.example.com' ,
468449 agent_card = agent_card ,
469450 interceptors = [interceptor ],
470451 )
@@ -504,6 +485,7 @@ async def test_extensions_added_to_request(
504485 extensions = ['https://example.com/ext1' ]
505486 transport = JsonRpcTransport (
506487 httpx_client = mock_httpx_client ,
488+ url = 'http://test-agent.example.com' ,
507489 agent_card = agent_card ,
508490 extensions = extensions ,
509491 )
@@ -547,6 +529,7 @@ async def test_send_message_streaming_server_error_propagates(
547529 """Test that send_message_streaming propagates server errors (e.g., 403, 500) directly."""
548530 client = JsonRpcTransport (
549531 httpx_client = mock_httpx_client ,
532+ url = 'http://test-agent.example.com' ,
550533 agent_card = agent_card ,
551534 )
552535 request = create_send_message_request (text = 'Error stream' )
@@ -577,41 +560,6 @@ async def empty_aiter():
577560 assert exc_info .value .status_code == 403
578561 mock_aconnect_sse .assert_called_once ()
579562
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 ()
603-
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- )
614-
615563 @pytest .mark .asyncio
616564 async def test_get_card_with_extended_card_support_with_extensions (
617565 self , mock_httpx_client : AsyncMock , agent_card : AgentCard
@@ -626,6 +574,7 @@ async def test_get_card_with_extended_card_support_with_extensions(
626574
627575 client = JsonRpcTransport (
628576 httpx_client = mock_httpx_client ,
577+ url = 'http://test-agent.example.com' ,
629578 agent_card = agent_card ,
630579 extensions = extensions ,
631580 )
0 commit comments