mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add accept keyword to Media selector (#145527)
* Add accept keyword to Media selector * Adjust test
This commit is contained in:
parent
97f3bb3da5
commit
7cccdf2205
@ -1020,11 +1020,15 @@ class MediaSelector(Selector[MediaSelectorConfig]):
|
|||||||
|
|
||||||
selector_type = "media"
|
selector_type = "media"
|
||||||
|
|
||||||
CONFIG_SCHEMA = BASE_SELECTOR_CONFIG_SCHEMA
|
CONFIG_SCHEMA = BASE_SELECTOR_CONFIG_SCHEMA.extend(
|
||||||
|
{
|
||||||
|
vol.Optional("accept"): [str],
|
||||||
|
}
|
||||||
|
)
|
||||||
DATA_SCHEMA = vol.Schema(
|
DATA_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
# Although marked as optional in frontend, this field is required
|
# If accept is set, the entity_id field will not be present
|
||||||
vol.Required("entity_id"): cv.entity_id_or_uuid,
|
vol.Optional("entity_id"): cv.entity_id_or_uuid,
|
||||||
# Although marked as optional in frontend, this field is required
|
# Although marked as optional in frontend, this field is required
|
||||||
vol.Required("media_content_id"): str,
|
vol.Required("media_content_id"): str,
|
||||||
# Although marked as optional in frontend, this field is required
|
# Although marked as optional in frontend, this field is required
|
||||||
|
@ -1125,7 +1125,7 @@ async def test_selector_serializer(
|
|||||||
"media_content_type": {"type": "string"},
|
"media_content_type": {"type": "string"},
|
||||||
"metadata": {"type": "object", "additionalProperties": True},
|
"metadata": {"type": "object", "additionalProperties": True},
|
||||||
},
|
},
|
||||||
"required": ["entity_id", "media_content_id", "media_content_type"],
|
"required": ["media_content_id", "media_content_type"],
|
||||||
}
|
}
|
||||||
assert selector_serializer(selector.NumberSelector({"mode": "box"})) == {
|
assert selector_serializer(selector.NumberSelector({"mode": "box"})) == {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
@ -817,6 +817,23 @@ def test_theme_selector_schema(schema, valid_selections, invalid_selections) ->
|
|||||||
),
|
),
|
||||||
(None, "abc", {}),
|
(None, "abc", {}),
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
{
|
||||||
|
"accept": ["image/*"],
|
||||||
|
},
|
||||||
|
(
|
||||||
|
{
|
||||||
|
"media_content_id": "abc",
|
||||||
|
"media_content_type": "def",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"media_content_id": "abc",
|
||||||
|
"media_content_type": "def",
|
||||||
|
"metadata": {},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(None, "abc", {}),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_media_selector_schema(schema, valid_selections, invalid_selections) -> None:
|
def test_media_selector_schema(schema, valid_selections, invalid_selections) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user