2017-02-12 01:29:05 +00:00
|
|
|
"""Test config init."""
|
2017-02-14 05:34:36 +00:00
|
|
|
|
|
|
|
from homeassistant.components import config
|
2019-12-08 16:57:28 +00:00
|
|
|
from homeassistant.const import EVENT_COMPONENT_LOADED
|
|
|
|
from homeassistant.setup import ATTR_COMPONENT, async_setup_component
|
2017-02-12 01:29:05 +00:00
|
|
|
|
2020-04-30 20:29:50 +00:00
|
|
|
from tests.async_mock import patch
|
|
|
|
from tests.common import mock_component
|
2017-02-12 01:29:05 +00:00
|
|
|
|
|
|
|
|
2020-01-01 23:16:27 +00:00
|
|
|
async def test_config_setup(hass, loop):
|
2017-02-12 01:29:05 +00:00
|
|
|
"""Test it sets up hassbian."""
|
2020-01-01 23:16:27 +00:00
|
|
|
await async_setup_component(hass, "config", {})
|
2019-07-31 19:25:30 +00:00
|
|
|
assert "config" in hass.config.components
|
2017-02-14 05:34:36 +00:00
|
|
|
|
|
|
|
|
2020-01-01 23:16:27 +00:00
|
|
|
async def test_load_on_demand_already_loaded(hass, aiohttp_client):
|
2017-02-14 05:34:36 +00:00
|
|
|
"""Test getting suites."""
|
2019-07-31 19:25:30 +00:00
|
|
|
mock_component(hass, "zwave")
|
2017-02-14 05:34:36 +00:00
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
with patch.object(config, "SECTIONS", []), patch.object(
|
|
|
|
config, "ON_DEMAND", ["zwave"]
|
2020-04-30 20:29:50 +00:00
|
|
|
), patch(
|
|
|
|
"homeassistant.components.config.zwave.async_setup", return_value=True
|
|
|
|
) as stp:
|
2017-02-14 05:34:36 +00:00
|
|
|
|
2020-01-01 23:16:27 +00:00
|
|
|
await async_setup_component(hass, "config", {})
|
2017-02-14 05:34:36 +00:00
|
|
|
|
2020-01-01 23:16:27 +00:00
|
|
|
await hass.async_block_till_done()
|
2017-02-14 05:34:36 +00:00
|
|
|
assert stp.called
|
|
|
|
|
|
|
|
|
2020-01-01 23:16:27 +00:00
|
|
|
async def test_load_on_demand_on_load(hass, aiohttp_client):
|
2017-02-14 05:34:36 +00:00
|
|
|
"""Test getting suites."""
|
2019-07-31 19:25:30 +00:00
|
|
|
with patch.object(config, "SECTIONS", []), patch.object(
|
|
|
|
config, "ON_DEMAND", ["zwave"]
|
|
|
|
):
|
2020-01-01 23:16:27 +00:00
|
|
|
await async_setup_component(hass, "config", {})
|
2017-02-14 05:34:36 +00:00
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
assert "config.zwave" not in hass.config.components
|
2017-02-14 05:34:36 +00:00
|
|
|
|
2020-04-30 20:29:50 +00:00
|
|
|
with patch(
|
|
|
|
"homeassistant.components.config.zwave.async_setup", return_value=True
|
|
|
|
) as stp:
|
2019-07-31 19:25:30 +00:00
|
|
|
hass.bus.async_fire(EVENT_COMPONENT_LOADED, {ATTR_COMPONENT: "zwave"})
|
2020-01-01 23:16:27 +00:00
|
|
|
await hass.async_block_till_done()
|
2017-02-14 05:34:36 +00:00
|
|
|
|
|
|
|
assert stp.called
|