You've already forked adk-python
mirror of
https://github.com/encounter/adk-python.git
synced 2026-03-30 10:57:20 -07:00
chore: skip mcp and a2a tests for python 3.9
PiperOrigin-RevId: 773785385
This commit is contained in:
committed by
Copybara-Service
parent
2f716ada7f
commit
ffcba70686
@@ -13,18 +13,43 @@
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import sys
|
||||
from unittest.mock import Mock
|
||||
from unittest.mock import patch
|
||||
|
||||
from a2a import types as a2a_types
|
||||
from google.adk.a2a.converters.part_converter import A2A_DATA_PART_METADATA_TYPE_FUNCTION_CALL
|
||||
from google.adk.a2a.converters.part_converter import A2A_DATA_PART_METADATA_TYPE_FUNCTION_RESPONSE
|
||||
from google.adk.a2a.converters.part_converter import A2A_DATA_PART_METADATA_TYPE_KEY
|
||||
from google.adk.a2a.converters.part_converter import convert_a2a_part_to_genai_part
|
||||
from google.adk.a2a.converters.part_converter import convert_genai_part_to_a2a_part
|
||||
from google.genai import types as genai_types
|
||||
import pytest
|
||||
|
||||
# Skip all tests in this module if Python version is less than 3.10
|
||||
pytestmark = pytest.mark.skipif(
|
||||
sys.version_info < (3, 10), reason="A2A tool requires Python 3.10+"
|
||||
)
|
||||
|
||||
# Import dependencies with version checking
|
||||
try:
|
||||
from a2a import types as a2a_types
|
||||
from google.adk.a2a.converters.part_converter import A2A_DATA_PART_METADATA_TYPE_FUNCTION_CALL
|
||||
from google.adk.a2a.converters.part_converter import A2A_DATA_PART_METADATA_TYPE_FUNCTION_RESPONSE
|
||||
from google.adk.a2a.converters.part_converter import A2A_DATA_PART_METADATA_TYPE_KEY
|
||||
from google.adk.a2a.converters.part_converter import convert_a2a_part_to_genai_part
|
||||
from google.adk.a2a.converters.part_converter import convert_genai_part_to_a2a_part
|
||||
from google.genai import types as genai_types
|
||||
except ImportError as e:
|
||||
if sys.version_info < (3, 10):
|
||||
# Create dummy classes to prevent NameError during test collection
|
||||
# Tests will be skipped anyway due to pytestmark
|
||||
class DummyTypes:
|
||||
pass
|
||||
|
||||
a2a_types = DummyTypes()
|
||||
genai_types = DummyTypes()
|
||||
A2A_DATA_PART_METADATA_TYPE_FUNCTION_CALL = "function_call"
|
||||
A2A_DATA_PART_METADATA_TYPE_FUNCTION_RESPONSE = "function_response"
|
||||
A2A_DATA_PART_METADATA_TYPE_KEY = "type"
|
||||
convert_a2a_part_to_genai_part = lambda x: None
|
||||
convert_genai_part_to_a2a_part = lambda x: None
|
||||
else:
|
||||
raise e
|
||||
|
||||
|
||||
class TestConvertA2aPartToGenaiPart:
|
||||
"""Test cases for convert_a2a_part_to_genai_part function."""
|
||||
|
||||
@@ -20,13 +20,35 @@ from unittest.mock import AsyncMock
|
||||
from unittest.mock import Mock
|
||||
from unittest.mock import patch
|
||||
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import MCPSessionManager
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import retry_on_closed_resource
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import SseConnectionParams
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import StdioConnectionParams
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams
|
||||
import pytest
|
||||
|
||||
# Skip all tests in this module if Python version is less than 3.10
|
||||
pytestmark = pytest.mark.skipif(
|
||||
sys.version_info < (3, 10), reason="MCP tool requires Python 3.10+"
|
||||
)
|
||||
|
||||
# Import dependencies with version checking
|
||||
try:
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import MCPSessionManager
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import retry_on_closed_resource
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import SseConnectionParams
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import StdioConnectionParams
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams
|
||||
except ImportError as e:
|
||||
if sys.version_info < (3, 10):
|
||||
# Create dummy classes to prevent NameError during test collection
|
||||
# Tests will be skipped anyway due to pytestmark
|
||||
class DummyClass:
|
||||
pass
|
||||
|
||||
MCPSessionManager = DummyClass
|
||||
retry_on_closed_resource = lambda x: x
|
||||
SseConnectionParams = DummyClass
|
||||
StdioConnectionParams = DummyClass
|
||||
StreamableHTTPConnectionParams = DummyClass
|
||||
else:
|
||||
raise e
|
||||
|
||||
# Import real MCP classes
|
||||
try:
|
||||
from mcp import StdioServerParameters
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import sys
|
||||
from typing import Any
|
||||
from typing import Dict
|
||||
from unittest.mock import AsyncMock
|
||||
from unittest.mock import Mock
|
||||
from unittest.mock import patch
|
||||
@@ -23,14 +25,33 @@ from google.adk.auth.auth_credential import HttpAuth
|
||||
from google.adk.auth.auth_credential import HttpCredentials
|
||||
from google.adk.auth.auth_credential import OAuth2Auth
|
||||
from google.adk.auth.auth_credential import ServiceAccount
|
||||
from google.adk.auth.auth_schemes import AuthScheme
|
||||
from google.adk.auth.auth_schemes import AuthSchemeType
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import MCPSessionManager
|
||||
from google.adk.tools.mcp_tool.mcp_tool import MCPTool
|
||||
from google.adk.tools.tool_context import ToolContext
|
||||
from google.genai.types import FunctionDeclaration
|
||||
import pytest
|
||||
|
||||
# Skip all tests in this module if Python version is less than 3.10
|
||||
pytestmark = pytest.mark.skipif(
|
||||
sys.version_info < (3, 10), reason="MCP tool requires Python 3.10+"
|
||||
)
|
||||
|
||||
# Import dependencies with version checking
|
||||
try:
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import MCPSessionManager
|
||||
from google.adk.tools.mcp_tool.mcp_tool import MCPTool
|
||||
from google.adk.tools.tool_context import ToolContext
|
||||
from google.genai.types import FunctionDeclaration
|
||||
except ImportError as e:
|
||||
if sys.version_info < (3, 10):
|
||||
# Create dummy classes to prevent NameError during test collection
|
||||
# Tests will be skipped anyway due to pytestmark
|
||||
class DummyClass:
|
||||
pass
|
||||
|
||||
MCPSessionManager = DummyClass
|
||||
MCPTool = DummyClass
|
||||
ToolContext = DummyClass
|
||||
FunctionDeclaration = DummyClass
|
||||
else:
|
||||
raise e
|
||||
|
||||
|
||||
# Mock MCP Tool from mcp.types
|
||||
class MockMCPTool:
|
||||
|
||||
@@ -14,32 +14,49 @@
|
||||
|
||||
from io import StringIO
|
||||
import sys
|
||||
import unittest
|
||||
from unittest.mock import AsyncMock
|
||||
from unittest.mock import Mock
|
||||
from unittest.mock import patch
|
||||
|
||||
from google.adk.agents.readonly_context import ReadonlyContext
|
||||
from google.adk.auth.auth_credential import AuthCredential
|
||||
from google.adk.auth.auth_schemes import AuthScheme
|
||||
from google.adk.auth.auth_schemes import AuthSchemeType
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import MCPSessionManager
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import SseConnectionParams
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import StdioConnectionParams
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams
|
||||
from google.adk.tools.mcp_tool.mcp_tool import MCPTool
|
||||
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset
|
||||
import pytest
|
||||
|
||||
# Import the real MCP classes for proper instantiation
|
||||
try:
|
||||
from mcp import StdioServerParameters
|
||||
except ImportError:
|
||||
# Create a mock if MCP is not available
|
||||
class StdioServerParameters:
|
||||
# Skip all tests in this module if Python version is less than 3.10
|
||||
pytestmark = pytest.mark.skipif(
|
||||
sys.version_info < (3, 10), reason="MCP tool requires Python 3.10+"
|
||||
)
|
||||
|
||||
def __init__(self, command="test_command", args=None):
|
||||
self.command = command
|
||||
self.args = args or []
|
||||
# Import dependencies with version checking
|
||||
try:
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import MCPSessionManager
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import SseConnectionParams
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import StdioConnectionParams
|
||||
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams
|
||||
from google.adk.tools.mcp_tool.mcp_tool import MCPTool
|
||||
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset
|
||||
from mcp import StdioServerParameters
|
||||
except ImportError as e:
|
||||
if sys.version_info < (3, 10):
|
||||
# Create dummy classes to prevent NameError during test collection
|
||||
# Tests will be skipped anyway due to pytestmark
|
||||
class DummyClass:
|
||||
pass
|
||||
|
||||
class StdioServerParameters:
|
||||
|
||||
def __init__(self, command="test_command", args=None):
|
||||
self.command = command
|
||||
self.args = args or []
|
||||
|
||||
MCPSessionManager = DummyClass
|
||||
SseConnectionParams = DummyClass
|
||||
StdioConnectionParams = DummyClass
|
||||
StreamableHTTPConnectionParams = DummyClass
|
||||
MCPTool = DummyClass
|
||||
MCPToolset = DummyClass
|
||||
else:
|
||||
raise e
|
||||
|
||||
|
||||
class MockMCPTool:
|
||||
|
||||
Reference in New Issue
Block a user