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:
@@ -86,8 +86,22 @@ class TestImageSupportIntegration:
|
|||||||
mock_client = Mock()
|
mock_client = Mock()
|
||||||
mock_redis.return_value = mock_client
|
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"})
|
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(
|
success = add_turn(
|
||||||
thread_id=thread_id,
|
thread_id=thread_id,
|
||||||
role="user",
|
role="user",
|
||||||
@@ -302,9 +316,23 @@ class TestImageSupportIntegration:
|
|||||||
mock_client = Mock()
|
mock_client = Mock()
|
||||||
mock_redis.return_value = mock_client
|
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
|
# Create initial thread with chat tool
|
||||||
thread_id = create_thread("chat", {"initial": "context"})
|
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 with images from chat tool
|
||||||
add_turn(
|
add_turn(
|
||||||
thread_id=thread_id,
|
thread_id=thread_id,
|
||||||
@@ -424,8 +452,22 @@ class TestImageSupportIntegration:
|
|||||||
mock_client = Mock()
|
mock_client = Mock()
|
||||||
mock_redis.return_value = mock_client
|
mock_redis.return_value = mock_client
|
||||||
|
|
||||||
|
# Mock the Redis operations to return success
|
||||||
|
mock_client.set.return_value = True
|
||||||
|
|
||||||
# Create parent thread with images
|
# Create parent thread with images
|
||||||
parent_thread_id = create_thread("chat", {"parent": "context"})
|
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(
|
add_turn(
|
||||||
thread_id=parent_thread_id,
|
thread_id=parent_thread_id,
|
||||||
role="user",
|
role="user",
|
||||||
|
|||||||
@@ -1078,6 +1078,7 @@ When recommending searches, be specific about what information you need and why
|
|||||||
_, data = image_path.split(",", 1)
|
_, data = image_path.split(",", 1)
|
||||||
# Base64 encoding increases size by ~33%, so decode to get actual size
|
# Base64 encoding increases size by ~33%, so decode to get actual size
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
actual_size = len(base64.b64decode(data))
|
actual_size = len(base64.b64decode(data))
|
||||||
|
|
||||||
actual_size = len(base64.b64decode(data))
|
actual_size = len(base64.b64decode(data))
|
||||||
|
|||||||
Reference in New Issue
Block a user