Skip to content

Commit 23293c2

Browse files
committed
tests: remove bloat tests
1 parent 70817ae commit 23293c2

File tree

1 file changed

+0
-87
lines changed

1 file changed

+0
-87
lines changed

tests/strands/tools/mcp/test_mcp_client.py

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -422,93 +422,6 @@ def test_call_tool_sync_without_structured_content(mock_transport, mock_session)
422422
assert result.get("structuredContent") is None
423423

424424

425-
@pytest.mark.asyncio
426-
async def test_call_tool_async_without_structured_content(mock_transport, mock_session):
427-
"""Test that call_tool_async works correctly when no structured content is provided."""
428-
mock_content = MCPTextContent(type="text", text="Test message")
429-
mock_result = MCPCallToolResult(isError=False, content=[mock_content]) # No structuredContent
430-
mock_session.call_tool.return_value = mock_result
431-
432-
with MCPClient(mock_transport["transport_callable"]) as client:
433-
with (
434-
patch("asyncio.run_coroutine_threadsafe") as mock_run_coroutine_threadsafe,
435-
patch("asyncio.wrap_future") as mock_wrap_future,
436-
):
437-
mock_future = MagicMock()
438-
mock_run_coroutine_threadsafe.return_value = mock_future
439-
440-
async def mock_awaitable():
441-
return mock_result
442-
443-
mock_wrap_future.return_value = mock_awaitable()
444-
445-
result = await client.call_tool_async(
446-
tool_use_id="test-123", name="test_tool", arguments={"param": "value"}
447-
)
448-
449-
assert result["status"] == "success"
450-
assert result["toolUseId"] == "test-123"
451-
assert len(result["content"]) == 1
452-
assert result["content"][0]["text"] == "Test message"
453-
# structuredContent should be None when not provided by MCP
454-
assert result.get("structuredContent") is None
455-
456-
457-
def test_structured_content_validation():
458-
"""Test that structured content is properly validated and handled."""
459-
# Test that MCPToolResult can be created with structured content
460-
structured_data = {"result": {"value": 42}, "metadata": {"timestamp": "2023-01-01"}}
461-
462-
result = MCPToolResult(
463-
status="success",
464-
toolUseId="test-123",
465-
content=[{"text": "Operation completed"}],
466-
structuredContent=structured_data,
467-
)
468-
469-
# Validate that structured content is accessible
470-
assert "structuredContent" in result
471-
assert result["structuredContent"] == structured_data
472-
assert result["structuredContent"]["result"]["value"] == 42
473-
assert result["structuredContent"]["metadata"]["timestamp"] == "2023-01-01"
474-
475-
# Test that regular content is still accessible
476-
assert result["content"][0]["text"] == "Operation completed"
477-
478-
# Test that MCPToolResult without structured content works
479-
result_no_structured = MCPToolResult(status="success", toolUseId="test-456", content=[{"text": "Simple operation"}])
480-
481-
assert result_no_structured.get("structuredContent") is None
482-
assert result_no_structured["content"][0]["text"] == "Simple operation"
483-
484-
485-
def test_structured_content_separation_from_content_array(mock_transport, mock_session):
486-
"""Test that structured content is NOT added to the content array (new behavior)."""
487-
mock_content = MCPTextContent(type="text", text="Tool executed successfully")
488-
structured_content = {"data": {"items": [1, 2, 3]}, "pagination": {"hasMore": False, "total": 3}}
489-
490-
mock_session.call_tool.return_value = MCPCallToolResult(
491-
isError=False, content=[mock_content], structuredContent=structured_content
492-
)
493-
494-
with MCPClient(mock_transport["transport_callable"]) as client:
495-
result = client.call_tool_sync(tool_use_id="test-789", name="data_tool", arguments={})
496-
497-
# Verify the content array only contains the original MCP content
498-
assert len(result["content"]) == 1
499-
assert result["content"][0]["text"] == "Tool executed successfully"
500-
501-
# Verify no JSON object was added to the content array (old behavior)
502-
for content_item in result["content"]:
503-
assert "json" not in content_item
504-
505-
# Verify structured content is in its own field (new behavior)
506-
assert "structuredContent" in result
507-
assert result["structuredContent"] == structured_content
508-
assert result["structuredContent"]["data"]["items"] == [1, 2, 3]
509-
assert result["structuredContent"]["pagination"]["hasMore"] is False
510-
511-
512425
def test_exception_when_future_not_running():
513426
"""Test exception handling when the future is not running."""
514427
# Create a client.with a mock transport

0 commit comments

Comments
 (0)