3939
4040@pytest .mark .asyncio
4141async def test_toolset_init_bool ():
42- toolset = SendA2uiToClientToolset (
43- a2ui_enabled = True , a2ui_schema = TEST_A2UI_SCHEMA
44- )
42+ toolset = SendA2uiToClientToolset (a2ui_enabled = True , a2ui_schema = TEST_A2UI_SCHEMA )
4543 ctx = MagicMock (spec = ReadonlyContext )
4644 assert await toolset ._resolve_a2ui_enabled (ctx ) == True
4745
@@ -54,9 +52,7 @@ async def test_toolset_init_bool():
5452async def test_toolset_init_callable ():
5553 enabled_mock = MagicMock (return_value = True )
5654 schema_mock = MagicMock (return_value = TEST_A2UI_SCHEMA )
57- toolset = SendA2uiToClientToolset (
58- a2ui_enabled = enabled_mock , a2ui_schema = schema_mock
59- )
55+ toolset = SendA2uiToClientToolset (a2ui_enabled = enabled_mock , a2ui_schema = schema_mock )
6056 ctx = MagicMock (spec = ReadonlyContext )
6157 assert await toolset ._resolve_a2ui_enabled (ctx ) == True
6258
@@ -88,19 +84,15 @@ async def async_schema(_ctx):
8884
8985@pytest .mark .asyncio
9086async def test_toolset_get_tools_enabled ():
91- toolset = SendA2uiToClientToolset (
92- a2ui_enabled = True , a2ui_schema = TEST_A2UI_SCHEMA
93- )
87+ toolset = SendA2uiToClientToolset (a2ui_enabled = True , a2ui_schema = TEST_A2UI_SCHEMA )
9488 tools = await toolset .get_tools (MagicMock (spec = ReadonlyContext ))
9589 assert len (tools ) == 1
9690 assert isinstance (tools [0 ], SendA2uiToClientToolset ._SendA2uiJsonToClientTool )
9791
9892
9993@pytest .mark .asyncio
10094async def test_toolset_get_tools_disabled ():
101- toolset = SendA2uiToClientToolset (
102- a2ui_enabled = False , a2ui_schema = TEST_A2UI_SCHEMA
103- )
95+ toolset = SendA2uiToClientToolset (a2ui_enabled = False , a2ui_schema = TEST_A2UI_SCHEMA )
10496 tools = await toolset .get_tools (MagicMock (spec = ReadonlyContext ))
10597 assert len (tools ) == 0
10698
@@ -113,20 +105,15 @@ async def test_toolset_get_tools_disabled():
113105
114106def test_send_tool_init ():
115107 tool = SendA2uiToClientToolset ._SendA2uiJsonToClientTool (TEST_A2UI_SCHEMA )
116- assert (
117- tool .name == SendA2uiToClientToolset ._SendA2uiJsonToClientTool .TOOL_NAME
118- )
108+ assert tool .name == SendA2uiToClientToolset ._SendA2uiJsonToClientTool .TOOL_NAME
119109 assert tool ._a2ui_schema == TEST_A2UI_SCHEMA
120110
121111
122112def test_send_tool_get_declaration ():
123113 tool = SendA2uiToClientToolset ._SendA2uiJsonToClientTool (TEST_A2UI_SCHEMA )
124114 declaration = tool ._get_declaration ()
125115 assert declaration is not None
126- assert (
127- declaration .name
128- == SendA2uiToClientToolset ._SendA2uiJsonToClientTool .TOOL_NAME
129- )
116+ assert declaration .name == SendA2uiToClientToolset ._SendA2uiJsonToClientTool .TOOL_NAME
130117 assert (
131118 SendA2uiToClientToolset ._SendA2uiJsonToClientTool .A2UI_JSON_ARG_NAME
132119 in declaration .parameters .properties
@@ -182,8 +169,8 @@ async def test_send_tool_run_async_valid():
182169
183170 valid_a2ui = [{"type" : "Text" , "text" : "Hello" }]
184171 args = {
185- SendA2uiToClientToolset ._SendA2uiJsonToClientTool .A2UI_JSON_ARG_NAME : (
186- json . dumps ( valid_a2ui )
172+ SendA2uiToClientToolset ._SendA2uiJsonToClientTool .A2UI_JSON_ARG_NAME : json . dumps (
173+ valid_a2ui
187174 )
188175 }
189176
@@ -205,8 +192,8 @@ async def test_send_tool_run_async_valid_list():
205192
206193 valid_a2ui = [{"type" : "Text" , "text" : "Hello" }]
207194 args = {
208- SendA2uiToClientToolset ._SendA2uiJsonToClientTool .A2UI_JSON_ARG_NAME : (
209- json . dumps ( valid_a2ui )
195+ SendA2uiToClientToolset ._SendA2uiJsonToClientTool .A2UI_JSON_ARG_NAME : json . dumps (
196+ valid_a2ui
210197 )
211198 }
212199
@@ -234,9 +221,7 @@ async def test_send_tool_run_async_missing_arg():
234221async def test_send_tool_run_async_invalid_json ():
235222 tool = SendA2uiToClientToolset ._SendA2uiJsonToClientTool (TEST_A2UI_SCHEMA )
236223 args = {
237- SendA2uiToClientToolset ._SendA2uiJsonToClientTool .A2UI_JSON_ARG_NAME : (
238- "{invalid"
239- )
224+ SendA2uiToClientToolset ._SendA2uiJsonToClientTool .A2UI_JSON_ARG_NAME : "{invalid"
240225 }
241226 result = await tool .run_async (args = args , tool_context = MagicMock ())
242227 assert "error" in result
@@ -248,8 +233,8 @@ async def test_send_tool_run_async_schema_validation_fail():
248233 tool = SendA2uiToClientToolset ._SendA2uiJsonToClientTool (TEST_A2UI_SCHEMA )
249234 invalid_a2ui = [{"type" : "Text" }] # Missing 'text'
250235 args = {
251- SendA2uiToClientToolset ._SendA2uiJsonToClientTool .A2UI_JSON_ARG_NAME : (
252- json . dumps ( invalid_a2ui )
236+ SendA2uiToClientToolset ._SendA2uiJsonToClientTool .A2UI_JSON_ARG_NAME : json . dumps (
237+ invalid_a2ui
253238 )
254239 }
255240 result = await tool .run_async (args = args , tool_context = MagicMock ())
@@ -307,9 +292,7 @@ def test_converter_convert_function_call_returns_empty():
307292 function_call = genai_types .FunctionCall (
308293 name = SendA2uiToClientToolset ._SendA2uiJsonToClientTool .TOOL_NAME ,
309294 args = {
310- SendA2uiToClientToolset ._SendA2uiJsonToClientTool .A2UI_JSON_ARG_NAME : (
311- "..."
312- )
295+ SendA2uiToClientToolset ._SendA2uiJsonToClientTool .A2UI_JSON_ARG_NAME : "..."
313296 },
314297 )
315298 part = genai_types .Part (function_call = function_call )
@@ -337,9 +320,7 @@ def test_converter_convert_empty_result_response():
337320 assert len (a2a_parts ) == 0
338321
339322
340- @patch (
341- "google.adk.a2a.converters.part_converter.convert_genai_part_to_a2a_part"
342- )
323+ @patch ("google.adk.a2a.converters.part_converter.convert_genai_part_to_a2a_part" )
343324def test_converter_convert_non_a2ui_function_call (mock_convert ):
344325 function_call = genai_types .FunctionCall (name = "other_tool" , args = {})
345326 part = genai_types .Part (function_call = function_call )
@@ -352,9 +333,7 @@ def test_converter_convert_non_a2ui_function_call(mock_convert):
352333 mock_convert .assert_called_once_with (part )
353334
354335
355- @patch (
356- "google.adk.a2a.converters.part_converter.convert_genai_part_to_a2a_part"
357- )
336+ @patch ("google.adk.a2a.converters.part_converter.convert_genai_part_to_a2a_part" )
358337def test_converter_convert_other_part (mock_convert ):
359338 part = genai_types .Part (text = "Hello" )
360339 mock_a2a_part = a2a_types .Part (root = a2a_types .TextPart (text = "Hello" ))
0 commit comments