mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Fix rest schema (#81857)
This commit is contained in:
parent
b5dfe8c6b9
commit
1baa5c12c0
@ -91,9 +91,8 @@ COMBINED_SCHEMA = vol.Schema(
|
|||||||
CONFIG_SCHEMA = vol.Schema(
|
CONFIG_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
DOMAIN: vol.All(
|
DOMAIN: vol.All(
|
||||||
# convert empty dict to empty list
|
|
||||||
lambda x: [] if x == {} else x,
|
|
||||||
cv.ensure_list,
|
cv.ensure_list,
|
||||||
|
cv.remove_falsy,
|
||||||
[COMBINED_SCHEMA],
|
[COMBINED_SCHEMA],
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -418,3 +418,19 @@ async def test_empty_config(hass: HomeAssistant) -> None:
|
|||||||
{DOMAIN: {}},
|
{DOMAIN: {}},
|
||||||
)
|
)
|
||||||
assert_setup_component(0, DOMAIN)
|
assert_setup_component(0, DOMAIN)
|
||||||
|
|
||||||
|
|
||||||
|
async def test_config_schema_via_packages(hass: HomeAssistant) -> None:
|
||||||
|
"""Test configuration via packages."""
|
||||||
|
packages = {
|
||||||
|
"pack_dict": {"rest": {}},
|
||||||
|
"pack_11": {"rest": {"resource": "http://url1"}},
|
||||||
|
"pack_list": {"rest": [{"resource": "http://url2"}]},
|
||||||
|
}
|
||||||
|
config = {hass_config.CONF_CORE: {hass_config.CONF_PACKAGES: packages}}
|
||||||
|
await hass_config.merge_packages_config(hass, config, packages)
|
||||||
|
|
||||||
|
assert len(config) == 2
|
||||||
|
assert len(config["rest"]) == 2
|
||||||
|
assert config["rest"][0]["resource"] == "http://url1"
|
||||||
|
assert config["rest"][1]["resource"] == "http://url2"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user