Complete Redis mocking fixes for image support integration tests
- Properly mock Redis client operations to support add_turn functionality - Set up initial thread contexts so add_turn can find existing threads - Mock Redis set operations to return success - Ensure all Redis-dependent tests use proper mock patterns - All 473 unit tests now pass 100% with proper isolation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -85,9 +85,23 @@ class TestImageSupportIntegration:
|
||||
"""Test adding a conversation turn with images."""
|
||||
mock_client = Mock()
|
||||
mock_redis.return_value = mock_client
|
||||
|
||||
|
||||
# Mock the Redis operations to return success
|
||||
mock_client.set.return_value = True
|
||||
|
||||
thread_id = create_thread("test_tool", {"initial": "context"})
|
||||
|
||||
# Set up initial thread context for add_turn to find
|
||||
initial_context = ThreadContext(
|
||||
thread_id=thread_id,
|
||||
created_at="2025-01-01T00:00:00Z",
|
||||
last_updated_at="2025-01-01T00:00:00Z",
|
||||
tool_name="test_tool",
|
||||
turns=[], # Empty initially
|
||||
initial_context={"initial": "context"},
|
||||
)
|
||||
mock_client.get.return_value = initial_context.model_dump_json()
|
||||
|
||||
success = add_turn(
|
||||
thread_id=thread_id,
|
||||
role="user",
|
||||
@@ -301,10 +315,24 @@ class TestImageSupportIntegration:
|
||||
"""Test that images are preserved across different tools in conversation."""
|
||||
mock_client = Mock()
|
||||
mock_redis.return_value = mock_client
|
||||
|
||||
|
||||
# Mock the Redis operations to return success
|
||||
mock_client.set.return_value = True
|
||||
|
||||
# Create initial thread with chat tool
|
||||
thread_id = create_thread("chat", {"initial": "context"})
|
||||
|
||||
# Set up initial thread context for add_turn to find
|
||||
initial_context = ThreadContext(
|
||||
thread_id=thread_id,
|
||||
created_at="2025-01-01T00:00:00Z",
|
||||
last_updated_at="2025-01-01T00:00:00Z",
|
||||
tool_name="chat",
|
||||
turns=[], # Empty initially
|
||||
initial_context={"initial": "context"},
|
||||
)
|
||||
mock_client.get.return_value = initial_context.model_dump_json()
|
||||
|
||||
# Add turn with images from chat tool
|
||||
add_turn(
|
||||
thread_id=thread_id,
|
||||
@@ -423,9 +451,23 @@ class TestImageSupportIntegration:
|
||||
"""Test that images work correctly with conversation thread chaining."""
|
||||
mock_client = Mock()
|
||||
mock_redis.return_value = mock_client
|
||||
|
||||
|
||||
# Mock the Redis operations to return success
|
||||
mock_client.set.return_value = True
|
||||
|
||||
# Create parent thread with images
|
||||
parent_thread_id = create_thread("chat", {"parent": "context"})
|
||||
|
||||
# Set up initial parent thread context for add_turn to find
|
||||
parent_context = ThreadContext(
|
||||
thread_id=parent_thread_id,
|
||||
created_at="2025-01-01T00:00:00Z",
|
||||
last_updated_at="2025-01-01T00:00:00Z",
|
||||
tool_name="chat",
|
||||
turns=[], # Empty initially
|
||||
initial_context={"parent": "context"},
|
||||
)
|
||||
mock_client.get.return_value = parent_context.model_dump_json()
|
||||
add_turn(
|
||||
thread_id=parent_thread_id,
|
||||
role="user",
|
||||
|
||||
@@ -1078,6 +1078,7 @@ When recommending searches, be specific about what information you need and why
|
||||
_, data = image_path.split(",", 1)
|
||||
# Base64 encoding increases size by ~33%, so decode to get actual size
|
||||
import base64
|
||||
|
||||
actual_size = len(base64.b64decode(data))
|
||||
|
||||
actual_size = len(base64.b64decode(data))
|
||||
|
||||
Reference in New Issue
Block a user