@@ -131,6 +131,42 @@ async def test_send_prompt_async_edit(
131131 os .remove (image_piece .original_value )
132132
133133
134+ async def test_send_prompt_async_edit_single_image_passes_tuple_not_list (
135+ image_target : OpenAIImageTarget ,
136+ ):
137+ image_piece = get_image_message_piece ()
138+ text_piece = MessagePiece (
139+ role = "user" ,
140+ conversation_id = image_piece .conversation_id ,
141+ original_value = "edit this image" ,
142+ converted_value = "edit this image" ,
143+ original_value_data_type = "text" ,
144+ converted_value_data_type = "text" ,
145+ )
146+
147+ mock_response = MagicMock ()
148+ mock_image = MagicMock ()
149+ mock_image .b64_json = "aGVsbG8="
150+ mock_response .data = [mock_image ]
151+
152+ with patch .object (image_target ._async_client .images , "edit" , new_callable = AsyncMock ) as mock_edit :
153+ mock_edit .return_value = mock_response
154+
155+ resp = await image_target .send_prompt_async (message = Message ([text_piece , image_piece ]))
156+ assert resp
157+
158+ call_kwargs = mock_edit .call_args [1 ]
159+ assert isinstance (call_kwargs ["image" ], tuple )
160+ assert len (call_kwargs ["image" ]) == 3
161+
162+ path = resp [0 ].message_pieces [0 ].original_value
163+ if os .path .isfile (path ):
164+ os .remove (path )
165+
166+ if os .path .isfile (image_piece .original_value ):
167+ os .remove (image_piece .original_value )
168+
169+
134170async def test_send_prompt_async_edit_multiple_images (
135171 image_target : OpenAIImageTarget ,
136172):
0 commit comments