Nicco Kunzmann 2025-09-22 19:25:00 +01:00
rodzic 51bcca7868
commit 015ada63aa
2 zmienionych plików z 12 dodań i 0 usunięć

Wyświetl plik

@ -73,6 +73,10 @@ class Image:
display: str | None = None,
):
"""Create a new image according to :rfc:`7986`."""
if uri is not None and b64data is not None:
raise ValueError("Image cannot have both URI and binary data (RFC 7986)")
if uri is None and b64data is None:
raise ValueError("Image must have either URI or binary data")
self.uri = uri
self.b64data = b64data
self.fmttype = fmttype

Wyświetl plik

@ -157,3 +157,11 @@ def test_create_image_with_vText_as_binary():
assert img.fmttype is None
assert img.altrep is None
assert img.display is None
def test_requires_uri_xor_binary():
"""Test forbidden parameter combinations."""
with pytest.raises(ValueError):
Image()
with pytest.raises(ValueError):
Image(b64data="", uri="http://example.com/image.png")