-
Notifications
You must be signed in to change notification settings - Fork 1.5k
tests: Add unit tests for mcp_tool #663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 17 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
683e86d
add unit_test for mcptool and mcptoolset
pkduongsu 8faa342
split mcp_tool and mcp_toolset tests
pkduongsu a6b0ad1
add conversion utils tests
pkduongsu 88a8f51
Merge branch 'main' into mcp-unit-tests
pkduongsu c4a23d9
fix import
pkduongsu e035f22
Merge branch 'mcp-unit-tests' of https://github.com/pkduongsu/adk-pyt…
pkduongsu df1658b
merge branch 'mcp-unit-tests'
pkduongsu cec6595
Delete uv.lock
pkduongsu b5adaf8
Merge branch 'main' of https://github.com/pkduongsu/adk-python into m…
pkduongsu d144074
Merge branch 'main' into mcp-unit-tests
pkduongsu f2e0dd4
Merge branch 'main' into mcp-unit-tests
pkdu
8000
ongsu b60a979
Delete src/google/adk/models/gemini_llm_connection.py
pkduongsu a43efc8
Delete src/google/adk/sessions/in_memory_session_service.py
pkduongsu e0896c4
Delete src/google/adk/tools/mcp_tool/mcp_toolset.py
pkduongsu cb7ac8e
Delete tests/unittests/cli/utils/test_cli_tools_click.py
pkduongsu 12c77c2
put files under mcp_tool folder
pkduongsu f9165b9
Merge branch 'mcp-unit-tests' of https://github.com/pkduongsu/adk-pyt…
pkduongsu 752bbc1
add tests for mcp toolset and mcp tool
pkduongsu 5504b79
Merge branch 'mcp-unit-tests' of https://github.com/pkduongsu/adk-pyt…
pkduongsu fdbf7fe
put files under mcp_tool folder
pkduongsu 05cea2b
Merge branch 'mcp-unit-tests' of https://github.com/pkduongsu/adk-pyt…
pkduongsu 42fc674
add tests for mcp_tool, mcp_toolset, conversion_utils
pkduongsu 17874f9
Merge pull request #1 from pkduongsu/recovery-branch
pkduongsu 8a673f9
update
pkduongsu 8ca465a
update branch
pkduongsu 60a976a
Merge branch 'mcp-unit-tests' of https://github.com/pkduongsu/adk-pyt…
pkduongsu a50d9e5
remove duplicate file
pkduongsu c86c0ad
Merge branch 'google:main' into mcp-unit-tests
pkduongsu 5089008
Merge branch 'google:main' into mcp-unit-tests
pkduongsu 19bfb19
improve test_coverage, fix test_mcp_toolset to match new refactored ver
pkduongsu 8c76197
"revert changes for mcp_session_manager"
pkduongsu f80ccf7
Merge branch 'google:main' into mcp-unit-tests
pkduongsu 9695052
Merge branch 'google:main' into mcp-unit-tests
pkduongsu e5d18b5
Merge branch 'main' into mcp-unit-tests
pkduongsu a49237a
Merge branch 'main' into mcp-unit-tests
pkduongsu d6a26bd
Merge branch 'main' into mcp-unit-tests
hangfei 4f61621
Merge branch 'main' into mcp-unit-tests
hangfei c0e1368
Merge branch 'google:main' into mcp-unit-tests
pkduongsu 71bf490
remove python 3.9 test
pkduongsu 0a5321a
Merge branch 'main' into mcp-unit-tests
pkduongsu e5372c6
Remove old test_mcp_tool
pkduongsu 68dd494
'remove old tests'
pkduongsu 842c8a0
Merge branch 'mcp-unit-tests' of https://github.com/pkduongsu/adk-pyt…
pkduongsu 891afb4
Merge branch 'main' into mcp-unit-tests
hangfei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
src/google/adk/tools/google_api_tool/google_api_tool_sets.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# Copyright 2025 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
import logging | ||
|
||
from .google_api_tool_set import GoogleApiToolSet | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
_bigquery_tool_set = None | ||
_calendar_tool_set = None | ||
_gmail_tool_set = None | ||
_youtube_tool_set = None | ||
_slides_tool_set = None | ||
_sheets_tool_set = None | ||
_docs_tool_set = None | ||
|
||
|
||
def __getattr__(name): | ||
"""This method dynamically loads and returns GoogleApiToolSet instances for | ||
|
||
various Google APIs. It uses a lazy loading approach, initializing each | ||
tool set only when it is first requested. This avoids unnecessary loading | ||
of tool sets that are not used in a given session. | ||
|
||
Args: | ||
name (str): The name of the tool set to retrieve (e.g., | ||
"bigquery_tool_set"). | ||
|
||
Returns: | ||
GoogleApiToolSet: The requested tool set instance. | ||
|
||
Raises: | ||
AttributeError: If the requested tool set name is not recognized. | ||
""" | ||
global _bigquery_tool_set, _calendar_tool_set, _gmail_tool_set, _youtube_tool_set, _slides_tool_set, _sheets_tool_set, _docs_tool_set | ||
|
||
match name: | ||
case "bigquery_tool_set": | ||
if _bigquery_tool_set is None: | ||
_bigquery_tool_set = GoogleApiToolSet.load_tool_set( | ||
api_name="bigquery", | ||
api_version="v2", | ||
) | ||
|
||
return _bigquery_tool_set | ||
|
||
case "calendar_tool_set": | ||
if _calendar_tool_set is None: | ||
_calendar_tool_set = GoogleApiToolSet.load_tool_set( | ||
api_name="calendar", | ||
api_version="v3", | ||
) | ||
|
||
return _calendar_tool_set | ||
|
||
case "gmail_tool_set": | ||
if _gmail_tool_set is None: | ||
_gmail_tool_set = GoogleApiToolSet.load_tool_set( | ||
api_name="gmail", | ||
api_version="v1", | ||
) | ||
|
||
return _gmail_tool_set | ||
|
||
case "youtube_tool_set": | ||
if _youtube_tool_set is None: | ||
_youtube_tool_set = GoogleApiToolSet.load_tool_set( | ||
api_name="youtube", | ||
api_version="v3", | ||
) | ||
|
||
return _youtube_tool_set | ||
|
||
case "slides_tool_set": | ||
if _slides_tool_set is None: | ||
_slides_tool_set = GoogleApiToolSet.load_tool_set( | ||
api_name="slides", | ||
api_version="v1", | ||
) | ||
|
||
return _slides_tool_set | ||
|
||
case "sheets_tool_set": | ||
if _sheets_tool_set is None: | ||
_sheets_tool_set = GoogleApiToolSet.load_tool_set( | ||
api_name="sheets", | ||
api_version="v4", | ||
) | ||
|
||
return _sheets_tool_set | ||
|
||
case "docs_tool_set": | ||
if _docs_tool_set is None: | ||
_docs_tool_set = GoogleApiToolSet.load_tool_set( | ||
api_name="docs", | ||
api_version="v1", | ||
) | ||
|
||
return _docs_tool_set |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.