Skip to content

Commit ede4bf4

Browse files
committed
test: openapi working in sub-app
1 parent 6a5482f commit ede4bf4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/server/apps/jsonrpc/test_serialization.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from unittest import mock
22

33
import pytest
4+
from fastapi import FastAPI
45

56
from pydantic import ValidationError
67
from 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'}]

0 commit comments

Comments
 (0)