@@ -52,24 +52,6 @@ def mock_openapi_toolset():
5252 yield mock_toolset
5353
5454
55- @pytest .fixture
56- def mock_openapi_toolset_with_multiple_tools_and_no_tools ():
57- with mock .patch (
58- "google.adk.tools.application_integration_tool.application_integration_toolset.OpenAPIToolset"
59- ) as mock_toolset :
60- mock_toolset_instance = mock .MagicMock ()
61- mock_rest_api_tool = mock .MagicMock (spec = rest_api_tool .RestApiTool )
62- mock_rest_api_tool .name = "Test Tool"
63- mock_rest_api_tool_2 = mock .MagicMock (spec = rest_api_tool .RestApiTool )
64- 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- ]
69- mock_toolset .return_value = mock_toolset_instance
70- yield mock_toolset
71-
72-
7355def get_mocked_parsed_operation (operation_id , attributes ):
7456 mock_openapi_spec_parser_instance = mock .MagicMock ()
7557 mock_parsed_operation = mock .MagicMock (spec = ParsedOperation )
@@ -162,17 +144,10 @@ def test_initialization_with_integration_and_trigger(
162144 integration_name = "test-integration"
163145 trigger_name = "test-trigger"
164146 toolset = ApplicationIntegrationToolset (
165- project , location , integration = integration_name , triggers = [ trigger_name ]
147+ project , location , integration = integration_name , trigger = trigger_name
166148 )
167149 mock_integration_client .assert_called_once_with (
168- project ,
169- location ,
170- integration_name ,
171- [trigger_name ],
172- None ,
173- None ,
174- None ,
175- None ,
150+ project , location , integration_name , trigger_name , None , None , None , None
176151 )
177152 mock_integration_client .return_value .get_openapi_spec_for_integration .assert_called_once ()
178153 mock_connections_client .assert_not_called ()
@@ -181,58 +156,6 @@ def test_initialization_with_integration_and_trigger(
181156 assert toolset .get_tools ()[0 ].name == "Test Tool"
182157
183158
184- def test_initialization_with_integration_and_list_of_triggers (
185- project ,
186- location ,
187- mock_integration_client ,
188- mock_connections_client ,
189- mock_openapi_toolset_with_multiple_tools_and_no_tools ,
190- ):
191- integration_name = "test-integration"
192- trigger_name = ["test-trigger1" , "test-trigger2" ]
193- toolset = ApplicationIntegrationToolset (
194- project , location , integration = integration_name , triggers = trigger_name
195- )
196- mock_integration_client .assert_called_once_with (
197- project ,
198- location ,
199- integration_name ,
200- trigger_name ,
201- None ,
202- None ,
203- None ,
204- None ,
205- )
206- mock_integration_client .return_value .get_openapi_spec_for_integration .assert_called_once ()
207- mock_connections_client .assert_not_called ()
208- mock_openapi_toolset_with_multiple_tools_and_no_tools .assert_called_once ()
209- assert len (toolset .get_tools ()) == 2
210- assert toolset .get_tools ()[0 ].name == "Test Tool"
211- assert toolset .get_tools ()[1 ].name == "Test Tool 2"
212-
213-
214- def test_initialization_with_integration_and_empty_trigger_list (
215- project ,
216- location ,
217- mock_integration_client ,
218- mock_connections_client ,
219- mock_openapi_toolset_with_multiple_tools_and_no_tools ,
220- ):
221- integration_name = "test-integration"
222- toolset = ApplicationIntegrationToolset (
223- project , location , integration = integration_name
224- )
225- mock_integration_client .assert_called_once_with (
226- project , location , integration_name , None , None , None , None , None
227- )
228- mock_integration_client .return_value .get_openapi_spec_for_integration .assert_called_once ()
229- mock_connections_client .assert_not_called ()
230- mock_openapi_toolset_with_multiple_tools_and_no_tools .assert_called_once ()
231- assert len (toolset .get_tools ()) == 2
232- assert toolset .get_tools ()[0 ].name == "Test Tool"
233- assert toolset .get_tools ()[1 ].name == "Test Tool 2"
234-
235-
236159def test_initialization_with_connection_and_entity_operations (
237160 project ,
238161 location ,
@@ -340,7 +263,16 @@ def test_initialization_without_required_params(project, location):
340263 " \\ (entity_operations or actions\\ )\\ ) should be provided."
341264 ),
342265 ):
343- ApplicationIntegrationToolset (project , location , triggers = ["test" ])
266+ ApplicationIntegrationToolset (project , location , integration = "test" )
267+
268+ with pytest .raises (
269+ ValueError ,
270+ match = (
271+ "Either \\ (integration and trigger\\ ) or \\ (connection and"
272+ " \\ (entity_operations or actions\\ )\\ ) should be provided."
273+ ),
274+ ):
275+ ApplicationIntegrationToolset (project , location , trigger = "test" )
344276
345277 with pytest .raises (
346278 ValueError ,
@@ -378,14 +310,14 @@ def test_initialization_with_service_account_credentials(
378310 project ,
379311 location ,
380312 integration = integration_name ,
381- triggers = [ trigger_name ] ,
313+ trigger = trigger_name ,
382314 service_account_json = service_account_json ,
383315 )
384316 mock_integration_client .assert_called_once_with (
385317 project ,
386318 location ,
387319 integration_name ,
388- [ trigger_name ] ,
320+ trigger_name ,
389321 None ,
390322 None ,
391323 None ,
@@ -408,17 +340,10 @@ def test_initialization_without_explicit_service_account_credentials(
408340 integration_name = "test-integration"
409341 trigger_name = "test-trigger"
410342 toolset = ApplicationIntegrationToolset (
411- project , location , integration = integration_name , triggers = [ trigger_name ]
343+ project , location , integration = integration_name , trigger = trigger_name
412344 )
413345 mock_integration_client .assert_called_once_with (
414- project ,
415- location ,
416- integration_name ,
417- [trigger_name ],
418- None ,
419- None ,
420- None ,
421- None ,
346+ project , location , integration_name , trigger_name , None , None , None , None
422347 )
423348 mock_openapi_toolset .assert_called_once ()
424349 _ , kwargs = mock_openapi_toolset .call_args
@@ -432,7 +357,7 @@ def test_get_tools(
432357 integration_name = "test-integration"
433358 trigger_name = "test-trigger"
434359 toolset = ApplicationIntegrationToolset (
435- project , location , integration = integration_name , triggers = [ trigger_name ]
360+ project , location , integration = integration_name , trigger = trigger_name
436361 )
437362 tools = toolset .get_tools ()
438363 assert len (tools ) == 1
0 commit comments