|
12 | 12 | # See the License for the specific language governing permissions and
|
13 | 13 | # limitations under the License.
|
14 | 14 |
|
| 15 | + |
15 | 16 | import json
|
16 | 17 | from unittest import mock
|
| 18 | + |
17 | 19 | from fastapi.openapi.models import Operation
|
18 | 20 | from google.adk.agents.readonly_context import ReadonlyContext
|
19 | 21 | from google.adk.auth import AuthCredentialTypes
|
|
22 | 24 | from google.adk.tools.application_integration_tool.application_integration_toolset import ApplicationIntegrationToolset
|
23 | 25 | from google.adk.tools.application_integration_tool.integration_connector_tool import IntegrationConnectorTool
|
24 | 26 | from google.adk.tools.openapi_tool.auth.auth_helpers import dict_to_auth_scheme
|
25 |
| -from google.adk.tools.openapi_tool.openapi_spec_parser import ParsedOperation, rest_api_tool |
| 27 | +from google.adk.tools.openapi_tool.openapi_spec_parser import ParsedOperation |
| 28 | +from google.adk.tools.openapi_tool.openapi_spec_parser import rest_api_tool |
26 | 29 | from google.adk.tools.openapi_tool.openapi_spec_parser.openapi_spec_parser import OperationEndpoint
|
27 | 30 | import pytest
|
28 | 31 |
|
@@ -489,7 +492,8 @@ def test_initialization_with_connection_details(
|
489 | 492 | )
|
490 | 493 |
|
491 | 494 |
|
492 |
| -def test_init_with_connection_and_custom_auth( |
| 495 | +@pytest.mark.asyncio |
| 496 | +async def test_init_with_connection_and_custom_auth( |
493 | 497 | mock_integration_client,
|
494 | 498 | mock_connections_client,
|
495 | 499 | mock_openapi_action_spec_parser,
|
@@ -548,16 +552,17 @@ def test_init_with_connection_and_custom_auth(
|
548 | 552 | tool_name, tool_instructions
|
549 | 553 | )
|
550 | 554 | mock_openapi_action_spec_parser.return_value.parse.assert_called_once()
|
551 |
| - assert len(toolset.get_tools()) == 1 |
552 |
| - assert toolset.get_tools()[0].name == "list_issues_operation" |
553 |
| - assert isinstance(toolset.get_tools()[0], IntegrationConnectorTool) |
554 |
| - assert toolset.get_tools()[0].action == "CustomAction" |
555 |
| - assert toolset.get_tools()[0].operation == "EXECUTE_ACTION" |
556 |
| - assert toolset.get_tools()[0].auth_scheme == oauth2_scheme |
557 |
| - assert toolset.get_tools()[0].auth_credential == auth_credential |
| 555 | + assert len(await toolset.get_tools()) == 1 |
| 556 | + assert (await toolset.get_tools())[0].name == "list_issues_operation" |
| 557 | + assert isinstance((await toolset.get_tools())[0], IntegrationConnectorTool) |
| 558 | + assert (await toolset.get_tools())[0]._action == "CustomAction" |
| 559 | + assert (await toolset.get_tools())[0]._operation == "EXECUTE_ACTION" |
| 560 | + assert (await toolset.get_tools())[0]._auth_scheme == oauth2_scheme |
| 561 | + assert (await toolset.get_tools())[0]._auth_credential == auth_credential |
558 | 562 |
|
559 | 563 |
|
560 |
| -def test_init_with_connection_with_auth_override_disabled_and_custom_auth( |
| 564 | +@pytest.mark.asyncio |
| 565 | +async def test_init_with_connection_with_auth_override_disabled_and_custom_auth( |
561 | 566 | mock_integration_client,
|
562 | 567 | mock_connections_client,
|
563 | 568 | mock_openapi_action_spec_parser,
|
@@ -616,10 +621,10 @@ def test_init_with_connection_with_auth_override_disabled_and_custom_auth(
|
616 | 621 | tool_name, tool_instructions
|
617 | 622 | )
|
618 | 623 | mock_openapi_action_spec_parser.return_value.parse.assert_called_once()
|
619 |
| - assert len(toolset.get_tools()) == 1 |
620 |
| - assert toolset.get_tools()[0].name == "list_issues_operation" |
621 |
| - assert isinstance(toolset.get_tools()[0], IntegrationConnectorTool) |
622 |
| - assert toolset.get_tools()[0].action == "CustomAction" |
623 |
| - assert toolset.get_tools()[0].operation == "EXECUTE_ACTION" |
624 |
| - assert not toolset.get_tools()[0].auth_scheme |
625 |
| - assert not toolset.get_tools()[0].auth_credential |
| 624 | + assert len(await toolset.get_tools()) == 1 |
| 625 | + assert (await toolset.get_tools())[0].name == "list_issues_operation" |
| 626 | + assert isinstance((await toolset.get_tools())[0], IntegrationConnectorTool) |
| 627 | + assert (await toolset.get_tools())[0]._action == "CustomAction" |
| 628 | + assert (await toolset.get_tools())[0]._operation == "EXECUTE_ACTION" |
| 629 | + assert not (await toolset.get_tools())[0]._auth_scheme |
| 630 | + assert not (await toolset.get_tools())[0]._auth_credential |
0 commit comments