test: update assertions for single-image tool result fix

Update test_translate_anthropic_messages_to_openai_tool_result_with_base64_image
and test_translate_anthropic_messages_to_openai_tool_result_with_url_image to
expect structured ChatCompletionImageObject list instead of plain string,
matching the fix in transformation.py.
This commit is contained in:
zhanghao 2026-04-13 10:27:26 +08:00
parent b510628bc2
commit fd63e6a3a9

View file

@ -750,10 +750,12 @@ def test_translate_anthropic_messages_to_openai_tool_result_with_base64_image():
break
assert tool_message is not None, "Tool message not found in result"
# Tool messages in OpenAI format have string content (data URL), not list
assert isinstance(tool_message["content"], str)
assert tool_message["content"].startswith("data:image/jpeg;base64,")
assert "/9j/4AAQSkZJRgABAQAAAQABAAD" in tool_message["content"]
# Tool messages with single image should have structured image_url content
assert isinstance(tool_message["content"], list)
assert len(tool_message["content"]) == 1
assert tool_message["content"][0]["type"] == "image_url"
assert tool_message["content"][0]["image_url"]["url"].startswith("data:image/jpeg;base64,")
assert "/9j/4AAQSkZJRgABAQAAAQABAAD" in tool_message["content"][0]["image_url"]["url"]
def test_translate_anthropic_messages_to_openai_tool_result_with_url_image():
@ -806,10 +808,12 @@ def test_translate_anthropic_messages_to_openai_tool_result_with_url_image():
break
assert tool_message is not None, "Tool message not found in result"
# Tool messages in OpenAI format have string content (URL), not list
assert isinstance(tool_message["content"], str)
# Tool messages with single image should have structured image_url content
assert isinstance(tool_message["content"], list)
assert len(tool_message["content"]) == 1
assert tool_message["content"][0]["type"] == "image_url"
assert (
tool_message["content"]
tool_message["content"][0]["image_url"]["url"]
== "https://i0.wp.com/picjumbo.com/wp-content/uploads/amazing-stone-path-in-forest-free-image.jpg"
)