Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions tests/cli/test_cli_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from vlmrun.cli._cli.chat import (
resolve_prompt,
build_messages,
)
from vlmrun.client.chat import (
extract_artifact_refs,
AVAILABLE_MODELS,
DEFAULT_MODEL,
Expand Down Expand Up @@ -244,20 +246,22 @@ def test_chat_unsupported_file_type(
assert result.exit_code == 1
assert "Unsupported file type" in result.stdout

@patch("vlmrun.cli._cli.chat.upload_files")
def test_chat_with_file_json_output(
self,
mock_upload,
runner,
config_file,
mock_client,
mock_openai_response,
tmp_path,
):
"""Test chat with file and JSON output."""
import sys

# Get the actual chat module (not the function)
chat_module = sys.modules["vlmrun.client.chat"]

# Setup mocks - return FileResponse
mock_upload.return_value = [
mock_file_response = [
FileResponse(
id="file-123",
filename="test.jpg",
Expand All @@ -274,7 +278,10 @@ def test_chat_with_file_json_output(
test_file = tmp_path / "test.jpg"
test_file.write_bytes(b"fake image data")

with patch.object(mock_client, "openai", mock_client.openai):
with (
patch.object(chat_module, "_upload_files", return_value=mock_file_response),
patch.object(mock_client, "openai", mock_client.openai),
):
_result = runner.invoke(
app,
[
Expand Down
Loading