@@ -52,24 +52,6 @@ def mock_openapi_toolset():
52
52
yield mock_toolset
53
53
54
54
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
-
73
55
def get_mocked_parsed_operation (operation_id , attributes ):
74
56
mock_openapi_spec_parser_instance = mock .MagicMock ()
75
57
mock_parsed_operation = mock .MagicMock (spec = ParsedOperation )
@@ -162,17 +144,10 @@ def test_initialization_with_integration_and_trigger(
162
144
integration_name = "test-integration"
163
145
trigger_name = "test-trigger"
164
146
toolset = ApplicationIntegrationToolset (
165
- project , location , integration = integration_name , triggers = [ trigger_name ]
147
+ project , location , integration = integration_name , trigger = trigger_name
166
148
)
167
149
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
176
151
)
177
152
mock_integration_client .return_value .get_openapi_spec_for_integration .assert_called_once ()
178
153
mock_connections_client .assert_not_called ()
@@ -181,58 +156,6 @@ def test_initialization_with_integration_and_trigger(
181
156
assert toolset .get_tools ()[0 ].name == "Test Tool"
182
157
183
158
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
-
236
159
def test_initialization_with_connection_and_entity_operations (
237
160
project ,
238
161
location ,
@@ -340,7 +263,16 @@ def test_initialization_without_required_params(project, location):
340
263
" \\ (entity_operations or actions\\ )\\ ) should be provided."
341
264
),
342
265
):
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" )
344
276
345
277
with pytest .raises (
346
278
ValueError ,
@@ -378,14 +310,14 @@ def test_initialization_with_service_account_credentials(
378
310
project ,
379
311
location ,
380
312
integration = integration_name ,
381
- triggers = [ trigger_name ] ,
313
+ trigger = trigger_name ,
382
314
service_account_json = service_account_json ,
383
315
)
384
316
mock_integration_client .assert_called_once_with (
385
317
project ,
386
318
location ,
387
319
integration_name ,
388
- [ trigger_name ] ,
320
+ trigger_name ,
389
321
None ,
390
322
None ,
391
323
None ,
@@ -408,17 +340,10 @@ def test_initialization_without_explicit_service_account_credentials(
408
340
integration_name = "test-integration"
409
341
trigger_name = "test-trigger"
410
342
toolset = ApplicationIntegrationToolset (
411
- project , location , integration = integration_name , triggers = [ trigger_name ]
343
+ project , location , integration = integration_name , trigger = trigger_name
412
344
)
413
345
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
422
347
)
423
348
mock_openapi_toolset .assert_called_once ()
424
349
_ , kwargs = mock_openapi_toolset .call_args
@@ -432,7 +357,7 @@ def test_get_tools(
432
357
integration_name = "test-integration"
433
358
trigger_name = "test-trigger"
434
359
toolset = ApplicationIntegrationToolset (
435
- project , location , integration = integration_name , triggers = [ trigger_name ]
360
+ project , location , integration = integration_name , trigger = trigger_name
436
361
)
437
362
tools = toolset .get_tools ()
438
363
assert len (tools ) == 1
0 commit comments