vibe/tests/core/test_build_attachment_counts.py
Clément Drouin 6bedf271ce
v2.17.0 (#822)
Co-authored-by: Clément Sirieix <clement.sirieix@mistral.ai>
Co-authored-by: Guillaume LE GOFF <guillaume.lgf@gmail.com>
Co-authored-by: Hdandria <henri.dandria@mistral.ai>
Co-authored-by: Ivana Dunisijevic <ivana.dunisijevic@mistral.ai>
Co-authored-by: Jean Burellier <sheplu@users.noreply.github.com>
Co-authored-by: Mathias Gesbert <mathias.gesbert@mistral.ai>
Co-authored-by: Mert Unsal <mert.unsal@mistral.ai>
Co-authored-by: Michel Thomazo <51709227+michelTho@users.noreply.github.com>
Co-authored-by: Paul VEZIA <166131032+le-codeur-rapide@users.noreply.github.com>
Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai>
Co-authored-by: Val <102326092+vdeva@users.noreply.github.com>
Co-authored-by: Vincent G <10739306+VinceOPS@users.noreply.github.com>
Co-authored-by: renovate-mistral[bot] <253709520+renovate-mistral[bot]@users.noreply.github.com>
Co-authored-by: Mistral Vibe <vibe@mistral.ai>
2026-06-19 11:01:24 +02:00

36 lines
1.1 KiB
Python

from __future__ import annotations
from pathlib import Path
from vibe.core.telemetry.build_metadata import build_attachment_counts
from vibe.core.telemetry.types import AttachmentKind
from vibe.core.types import FileImageSource, ImageAttachment, LLMMessage, Role
def _msg(images: list[ImageAttachment] | None) -> LLMMessage:
return LLMMessage(role=Role.user, content="hi", images=images)
def _image() -> ImageAttachment:
return ImageAttachment(
source=FileImageSource(path=Path("/tmp/x.png")),
alias="x.png",
mime_type="image/png",
)
def test_returns_empty_when_message_is_none() -> None:
assert build_attachment_counts(None, supports_images=True) == {}
def test_returns_empty_when_no_images() -> None:
assert build_attachment_counts(_msg(None), supports_images=True) == {}
def test_counts_images_when_model_supports_them() -> None:
counts = build_attachment_counts(_msg([_image(), _image()]), supports_images=True)
assert counts == {AttachmentKind.IMAGE: 2}
def test_drops_images_when_model_does_not_support_them() -> None:
assert build_attachment_counts(_msg([_image()]), supports_images=False) == {}