kopia lustrzana https://github.com/collective/icalendar
Check arguments for Image()
see https://github.com/collective/icalendar/pull/877#discussion_r2366353004pull/877/head
rodzic
51bcca7868
commit
015ada63aa
|
@ -73,6 +73,10 @@ class Image:
|
||||||
display: str | None = None,
|
display: str | None = None,
|
||||||
):
|
):
|
||||||
"""Create a new image according to :rfc:`7986`."""
|
"""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.uri = uri
|
||||||
self.b64data = b64data
|
self.b64data = b64data
|
||||||
self.fmttype = fmttype
|
self.fmttype = fmttype
|
||||||
|
|
|
@ -157,3 +157,11 @@ def test_create_image_with_vText_as_binary():
|
||||||
assert img.fmttype is None
|
assert img.fmttype is None
|
||||||
assert img.altrep is None
|
assert img.altrep is None
|
||||||
assert img.display 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")
|
||||||
|
|
Ładowanie…
Reference in New Issue