File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
tests/server/apps/jsonrpc Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 11from unittest import mock
22
33import pytest
4+ from fastapi import FastAPI
45
56from pydantic import ValidationError
67from starlette .testclient import TestClient
@@ -184,3 +185,23 @@ def test_handle_unicode_characters(agent_card_with_api_key: AgentCard):
184185 data = response .json ()
185186 assert 'error' not in data or data ['error' ] is None
186187 assert data ['result' ]['parts' ][0 ]['text' ] == f'Received: { unicode_text } '
188+
189+
190+ def test_fastapi_sub_application (
191+ agent_card_with_api_key : AgentCard ,
192+ ):
193+ """
194+ Tests that the A2AFastAPIApplication endpoint correctly passes the url in sub-application.
195+ """
196+ handler = mock .AsyncMock ()
197+ sub_app_instance = A2AFastAPIApplication (agent_card_with_api_key , handler )
198+ app_instance = FastAPI ()
199+ app_instance .mount ('/a2a' , sub_app_instance .build ())
200+ client = TestClient (app_instance )
201+
202+ response = client .get ('/a2a/openapi.json' )
203+ assert response .status_code == 200
204+ response_data = response .json ()
205+
206+ assert 'servers' in response_data
207+ assert response_data ['servers' ] == [{'url' : '/a2a' }]
You can’t perform that action at this time.
0 commit comments