@@ -47,7 +47,14 @@ def mock_openapi_toolset():
4747 mock_toolset_instance = mock .MagicMock ()
4848 mock_rest_api_tool = mock .MagicMock (spec = rest_api_tool .RestApiTool )
4949 mock_rest_api_tool .name = "Test Tool"
50- mock_toolset_instance .get_tools .return_value = [mock_rest_api_tool ]
50+
51+ # Create an async mock for the get_tools method
52+ async def mock_get_tools ():
53+ return [mock_rest_api_tool ]
54+
55+ # Assign the async mock function to get_tools
56+ mock_toolset_instance .get_tools = mock_get_tools
57+
5158 mock_toolset .return_value = mock_toolset_instance
5259 yield mock_toolset
5360
@@ -62,10 +69,12 @@ def mock_openapi_toolset_with_multiple_tools_and_no_tools():
6269 mock_rest_api_tool .name = "Test Tool"
6370 mock_rest_api_tool_2 = mock .MagicMock (spec = rest_api_tool .RestApiTool )
6471 mock_rest_api_tool_2 .name = "Test Tool 2"
65- mock_toolset_instance .get_tools .return_value = [
66- mock_rest_api_tool ,
67- mock_rest_api_tool_2 ,
68- ]
72+
73+ # Create an async mock for the get_tools method
74+ async def mock_get_tools ():
75+ return [mock_rest_api_tool , mock_rest_api_tool_2 ]
76+
77+ mock_toolset_instance .get_tools = mock_get_tools
6978 mock_toolset .return_value = mock_toolset_instance
7079 yield mock_toolset
7180
@@ -152,7 +161,8 @@ def connection_details():
152161 }
153162
154163
155- def test_initialization_with_integration_and_trigger (
164+ @pytest .mark .asyncio
165+ async def test_initialization_with_integration_and_trigger (
156166 project ,
157167 location ,
158168 mock_integration_client ,
@@ -170,11 +180,13 @@ def test_initialization_with_integration_and_trigger(
170180 mock_integration_client .return_value .get_openapi_spec_for_integration .assert_called_once ()
171181 mock_connections_client .assert_not_called ()
172182 mock_openapi_toolset .assert_called_once ()
173- assert len (toolset .get_tools ()) == 1
174- assert toolset .get_tools ()[0 ].name == "Test Tool"
183+ tools = await toolset .get_tools ()
184+ assert len (tools ) == 1
185+ assert tools [0 ].name == "Test Tool"
175186
176187
177- def test_initialization_with_integration_and_list_of_triggers (
188+ @pytest .mark .asyncio
189+ async def test_initialization_with_integration_and_list_of_triggers (
178190 project ,
179191 location ,
180192 mock_integration_client ,
@@ -199,12 +211,14 @@ def test_initialization_with_integration_and_list_of_triggers(
199211 mock_integration_client .return_value .get_openapi_spec_for_integration .assert_called_once ()
200212 mock_connections_client .assert_not_called ()
201213 mock_openapi_toolset_with_multiple_tools_and_no_tools .assert_called_once ()
202- assert len (toolset .get_tools ()) == 2
203- assert toolset .get_tools ()[0 ].name == "Test Tool"
204- assert toolset .get_tools ()[1 ].name == "Test Tool 2"
214+ tools = await toolset .get_tools ()
215+ assert len (tools ) == 2
216+ assert tools [0 ].name == "Test Tool"
217+ assert tools [1 ].name == "Test Tool 2"
205218
206219
207- def test_initialization_with_integration_and_empty_trigger_list (
220+ @pytest .mark .asyncio
221+ async def test_initialization_with_integration_and_empty_trigger_list (
208222 project ,
209223 location ,
210224 mock_integration_client ,
@@ -221,12 +235,14 @@ def test_initialization_with_integration_and_empty_trigger_list(
221235 mock_integration_client .return_value .get_openapi_spec_for_integration .assert_called_once ()
222236 mock_connections_client .assert_not_called ()
223237 mock_openapi_toolset_with_multiple_tools_and_no_tools .assert_called_once ()
224- assert len (toolset .get_tools ()) == 2
225- assert toolset .get_tools ()[0 ].name == "Test Tool"
226- assert toolset .get_tools ()[1 ].name == "Test Tool 2"
238+ tools = await toolset .get_tools ()
239+ assert len (tools ) == 2
240+ assert tools [0 ].name == "Test Tool"
241+ assert tools [1 ].name == "Test Tool 2"
227242
228243
229- def test_initialization_with_connection_and_entity_operations (
244+ @pytest .mark .asyncio
245+ async def test_initialization_with_connection_and_entity_operations (
230246 project ,
231247 location ,
232248 mock_integration_client ,
@@ -268,14 +284,17 @@ def test_initialization_with_connection_and_entity_operations(
268284 tool_name ,
269285 tool_instructions ,
270286 )
271- assert len (toolset .get_tools ()) == 1
272- assert toolset .get_tools ()[0 ].name == "list_issues"
273- assert isinstance (toolset .get_tools ()[0 ], IntegrationConnectorTool )
274- assert toolset .get_tools ()[0 ].entity == "Issues"
275- assert toolset .get_tools ()[0 ].operation == "LIST_ENTITIES"
287+
288+ tools = await toolset .get_tools ()
289+ assert len (tools ) == 1
290+ assert tools [0 ].name == "list_issues"
291+ assert isinstance (tools [0 ], IntegrationConnectorTool )
292+ assert tools [0 ].entity == "Issues"
293+ assert tools [0 ].operation == "LIST_ENTITIES"
276294
277295
278- def test_initialization_with_connection_and_actions (
296+ @pytest .mark .asyncio
297+ async def test_initialization_with_connection_and_actions (
279298 project ,
280299 location ,
281300 mock_integration_client ,
@@ -309,11 +328,12 @@ def test_initialization_with_connection_and_actions(
309328 tool_name , tool_instructions
310329 )
311330 mock_openapi_action_spec_parser .return_value .parse .assert_called_once ()
312- assert len (toolset .get_tools ()) == 1
313- assert toolset .get_tools ()[0 ].name == "list_issues_operation"
314- assert isinstance (toolset .get_tools ()[0 ], IntegrationConnectorTool )
315- assert toolset .get_tools ()[0 ].action == "CustomAction"
316- assert toolset .get_tools ()[0 ].operation == "EXECUTE_ACTION"
331+ tools = await toolset .get_tools ()
332+ assert len (tools ) == 1
333+ assert tools [0 ].name == "list_issues_operation"
334+ assert isinstance (tools [0 ], IntegrationConnectorTool )
335+ assert tools [0 ].action == "CustomAction"
336+ assert tools [0 ].operation == "EXECUTE_ACTION"
317337
318338
319339def test_initialization_without_required_params (project , location ):
@@ -412,15 +432,16 @@ def test_initialization_without_explicit_service_account_credentials(
412432 assert kwargs ["auth_credential" ].service_account .use_default_credential
413433
414434
415- def test_get_tools (
435+ @pytest .mark .asyncio
436+ async def test_get_tools (
416437 project , location , mock_integration_client , mock_openapi_toolset
417438):
418439 integration_name = "test-integration"
419440 triggers = ["test-trigger" ]
420441 toolset = ApplicationIntegrationToolset (
421442 project , location , integration = integration_name , triggers = triggers
422443 )
423- tools = toolset .get_tools ()
444+ tools = await toolset .get_tools ()
424445 assert len (tools ) == 1
425446 assert isinstance (tools [0 ], rest_api_tool .RestApiTool )
426447 assert tools [0 ].name == "Test Tool"
0 commit comments