From 9770efe9e1f7dc850127dbf5fa92b2e4337b8bae Mon Sep 17 00:00:00 2001 From: Yuneng Jiang Date: Fri, 15 May 2026 22:25:37 -0700 Subject: [PATCH] test(fireworks): mock document-inlining test instead of live call The live deepseek-v3p1 call kept hitting Fireworks NOT_FOUND because Fireworks rotates its serverless catalog and no externally-verifiable list exists. The [False] branch also never sent an image, so it only proved the model responded. Mock the HTTP post (mirrors test_global_disable_flag_with_transform_ messages_helper) and assert the real behavior: #transform=inline is appended to the PDF URL unless disabled. No network, no model dependency, and stronger coverage than the old live test. --- .../test_fireworks_ai_translation.py | 50 ++++++++++++------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/tests/llm_translation/test_fireworks_ai_translation.py b/tests/llm_translation/test_fireworks_ai_translation.py index de065dc451..47b95c27ab 100644 --- a/tests/llm_translation/test_fireworks_ai_translation.py +++ b/tests/llm_translation/test_fireworks_ai_translation.py @@ -93,10 +93,24 @@ class TestFireworksAIAudioTranscription(BaseLLMAudioTranscriptionTest): [True, False], ) def test_document_inlining_example(disable_add_transform_inline_image_block): - litellm.set_verbose = True - if disable_add_transform_inline_image_block is True: - with pytest.raises(Exception): - completion = litellm.completion( + """ + Document inlining appends ``#transform=inline`` to image/PDF URLs in the + outgoing request unless explicitly disabled. Assert the transform on the + serialized payload rather than making a live Fireworks call — the live + call only proved the model responded and broke whenever Fireworks rotated + its serverless model catalog. + """ + from unittest.mock import patch + + from litellm import completion + from litellm.llms.custom_httpx.http_handler import HTTPHandler + + client = HTTPHandler() + pdf_url = "https://storage.googleapis.com/fireworks-public/test/sample_resume.pdf" + + with patch.object(client, "post") as mock_post: + try: + completion( model="fireworks_ai/accounts/fireworks/models/deepseek-v3p1", messages=[ { @@ -104,9 +118,7 @@ def test_document_inlining_example(disable_add_transform_inline_image_block): "content": [ { "type": "image_url", - "image_url": { - "url": "https://storage.googleapis.com/fireworks-public/test/sample_resume.pdf" - }, + "image_url": {"url": pdf_url}, }, { "type": "text", @@ -116,19 +128,19 @@ def test_document_inlining_example(disable_add_transform_inline_image_block): } ], disable_add_transform_inline_image_block=disable_add_transform_inline_image_block, + client=client, ) - else: - completion = litellm.completion( - model="fireworks_ai/accounts/fireworks/models/deepseek-v3p1", - messages=[ - { - "role": "user", - "content": "this is a test request, write a short poem", - }, - ], - disable_add_transform_inline_image_block=disable_add_transform_inline_image_block, - ) - print(completion) + except Exception as e: + print(e) + + mock_post.assert_called_once() + json_data = json.loads(mock_post.call_args.kwargs["data"]) + sent_url = json_data["messages"][0]["content"][0]["image_url"]["url"] + if disable_add_transform_inline_image_block is True: + assert sent_url == pdf_url + assert "#transform=inline" not in sent_url + else: + assert sent_url == pdf_url + "#transform=inline" @pytest.mark.parametrize(