mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 18:48:22 +00:00
parent
3e8bea8fbd
commit
797ea3ace4
@ -89,6 +89,13 @@ COMBINED_SCHEMA = vol.Schema(
|
|||||||
)
|
)
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema(
|
CONFIG_SCHEMA = vol.Schema(
|
||||||
{DOMAIN: vol.All(cv.ensure_list, [COMBINED_SCHEMA])},
|
{
|
||||||
|
DOMAIN: vol.All(
|
||||||
|
# convert empty dict to empty list
|
||||||
|
lambda x: [] if x == {} else x,
|
||||||
|
cv.ensure_list,
|
||||||
|
[COMBINED_SCHEMA],
|
||||||
|
)
|
||||||
|
},
|
||||||
extra=vol.ALLOW_EXTRA,
|
extra=vol.ALLOW_EXTRA,
|
||||||
)
|
)
|
||||||
|
@ -18,7 +18,11 @@ from homeassistant.const import (
|
|||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util.dt import utcnow
|
from homeassistant.util.dt import utcnow
|
||||||
|
|
||||||
from tests.common import async_fire_time_changed, get_fixture_path
|
from tests.common import (
|
||||||
|
assert_setup_component,
|
||||||
|
async_fire_time_changed,
|
||||||
|
get_fixture_path,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@respx.mock
|
@respx.mock
|
||||||
@ -399,3 +403,17 @@ async def test_multiple_rest_endpoints(hass):
|
|||||||
assert hass.states.get("sensor.json_date_time").state == "07:11:08 PM"
|
assert hass.states.get("sensor.json_date_time").state == "07:11:08 PM"
|
||||||
assert hass.states.get("sensor.json_time").state == "07:11:39 PM"
|
assert hass.states.get("sensor.json_time").state == "07:11:39 PM"
|
||||||
assert hass.states.get("binary_sensor.binary_sensor").state == "on"
|
assert hass.states.get("binary_sensor.binary_sensor").state == "on"
|
||||||
|
|
||||||
|
|
||||||
|
async def test_empty_config(hass: HomeAssistant) -> None:
|
||||||
|
"""Test setup with empty configuration.
|
||||||
|
|
||||||
|
For example (with rest.yaml an empty file):
|
||||||
|
rest: !include rest.yaml
|
||||||
|
"""
|
||||||
|
assert await async_setup_component(
|
||||||
|
hass,
|
||||||
|
DOMAIN,
|
||||||
|
{DOMAIN: {}},
|
||||||
|
)
|
||||||
|
assert_setup_component(0, DOMAIN)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user