test: add Gemini video and audio integration tests

This commit is contained in:
Greyson LaLonde
2026-01-22 23:16:08 -05:00
parent f3efd2946a
commit 661d4d29b2
4 changed files with 196 additions and 1 deletions

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -9,13 +9,23 @@ from pathlib import Path
import pytest
from crewai.llm import LLM
from crewai_files import File, ImageFile, PDFFile, TextFile, format_multimodal_content
from crewai_files import (
AudioFile,
File,
ImageFile,
PDFFile,
TextFile,
VideoFile,
format_multimodal_content,
)
# Path to test data files
TEST_FIXTURES_DIR = Path(__file__).parent.parent.parent.parent / "crewai-files" / "tests" / "fixtures"
TEST_IMAGE_PATH = TEST_FIXTURES_DIR / "revenue_chart.png"
TEST_TEXT_PATH = TEST_FIXTURES_DIR / "review_guidelines.txt"
TEST_VIDEO_PATH = TEST_FIXTURES_DIR / "sample_video.mp4"
TEST_AUDIO_PATH = TEST_FIXTURES_DIR / "sample_audio.wav"
@pytest.fixture
@@ -30,6 +40,22 @@ def test_text_bytes() -> bytes:
return TEST_TEXT_PATH.read_bytes()
@pytest.fixture
def test_video_bytes() -> bytes:
"""Load test video bytes."""
if not TEST_VIDEO_PATH.exists():
pytest.skip("sample_video.mp4 fixture not found")
return TEST_VIDEO_PATH.read_bytes()
@pytest.fixture
def test_audio_bytes() -> bytes:
"""Load test audio bytes."""
if not TEST_AUDIO_PATH.exists():
pytest.skip("sample_audio.wav fixture not found")
return TEST_AUDIO_PATH.read_bytes()
# Minimal PDF for testing (real PDF structure)
MINIMAL_PDF = b"""%PDF-1.4
1 0 obj << /Type /Catalog /Pages 2 0 R >> endobj
@@ -226,6 +252,42 @@ class TestGeminiMultimodalIntegration:
assert isinstance(response, str)
assert len(response) > 0
@pytest.mark.vcr()
def test_analyze_video_file(self, test_video_bytes: bytes) -> None:
"""Test Gemini can analyze a video file."""
llm = LLM(model="gemini/gemini-2.0-flash")
files = {"video": VideoFile(source=test_video_bytes)}
messages = _build_multimodal_message(
llm,
"Describe what you see in this video in one sentence. Be brief.",
files,
)
response = llm.call(messages)
assert response
assert isinstance(response, str)
assert len(response) > 0
@pytest.mark.vcr()
def test_analyze_audio_file(self, test_audio_bytes: bytes) -> None:
"""Test Gemini can analyze an audio file."""
llm = LLM(model="gemini/gemini-2.0-flash")
files = {"audio": AudioFile(source=test_audio_bytes)}
messages = _build_multimodal_message(
llm,
"Describe what you hear in this audio in one sentence. Be brief.",
files,
)
response = llm.call(messages)
assert response
assert isinstance(response, str)
assert len(response) > 0
class TestLiteLLMMultimodalIntegration:
"""Integration tests for LiteLLM wrapper multimodal with real API calls."""