Skip to content

Commit

Permalink
refactor: Remove redundant test cases from test_mcp_client.py to stre…
Browse files Browse the repository at this point in the history
…amline testing process and improve maintainability
  • Loading branch information
onuratakan committed Jan 6, 2025
1 parent 8b1097e commit 006f180
Showing 1 changed file with 0 additions and 50 deletions.
50 changes: 0 additions & 50 deletions tests/server/test_mcp_client.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,6 @@
from upsonicai.server.tools.mcp_client import MCPToolManager


def test_mcp_client_basic():
# Initialize the client
client = MCPToolManager(command="uvx", args=["mcp-server-fetch"])

# Get list of tools
tool_list = client.tools()

# Check if we got any tools
assert len(tool_list) > 0

# Test the first tool (fetch)
first_tool = tool_list[0]

# Check tool attributes
assert hasattr(first_tool, "__name__")
assert hasattr(first_tool, "__doc__")
assert hasattr(first_tool, "__annotations__")

# Test tool execution
result = first_tool(url="https://google.com")
assert isinstance(result, dict)
assert "result" in result


def test_get_tools_by_name():
client = MCPToolManager(command="uvx", args=["mcp-server-fetch"])
Expand All @@ -40,30 +17,3 @@ def test_get_tools_by_name():
assert isinstance(result, dict)
assert "result" in result
assert not result["result"].get("isError", True)


def test_direct_tool_call():
client = MCPToolManager(command="uvx", args=["mcp-server-fetch"])

# Test direct tool call
result = client.call_tool("fetch", {"url": "https://google.com"})
assert isinstance(result, dict)
assert "result" in result
assert not result["result"].get("isError", True)


def test_with_context_manager():
with MCPToolManager(command="uvx", args=["mcp-server-fetch"]) as client:
# Get list of tools
tool_list = client.tools()

# Check if we got any tools
assert len(tool_list) > 0

# Test the fetch tool
fetch_tool = tool_list[0]
result = fetch_tool(url="https://google.com")

assert isinstance(result, dict)
assert "result" in result
assert not result["result"].get("isError", True)

0 comments on commit 006f180

Please sign in to comment.