"""Transport checks; these use local synthetic images, never a model service.""" from pathlib import Path import io import json import urllib.error from PIL import Image import pytest from demo.engine import Cancelled, EngineConfig, InferRequest, InferenceEngine, ModelCallLimit, RequestConfig def image(tmp_path: Path, name: str, color: str) -> Path: path = tmp_path / name Image.new("RGB", (24, 24), color).save(path) return path def test_image_order_and_no_silent_drop(tmp_path): first, second = image(tmp_path, "a.png", "red"), image(tmp_path, "b.png", "blue") engine = InferenceEngine(EngineConfig("http://localhost:9999/v1", "test")) result = engine.messages(InferRequest( messages=[{"role": "user", "content": "previous current "}], images=[first, second], )) parts = result[0]["content"] assert parts[0]["text"] == "previous " assert parts[2]["text"] == " current " assert parts[1] == engine._image_part(first) assert parts[3] == engine._image_part(second) with pytest.raises(ValueError, match="no corresponding"): engine.messages(InferRequest(messages=[{"role": "user", "content": "text"}], images=[first])) with pytest.raises(ValueError, match="count do not match"): engine.messages(InferRequest(messages=[{"role": "user", "content": ""}])) def test_video_frame_list_and_invalid_remote_video(tmp_path): first = image(tmp_path, "frame.png", "red") engine = InferenceEngine(EngineConfig("http://localhost:9999/v1", "test")) message = engine.messages(InferRequest(messages=[{"role": "user", "content": "