2017-02-12 01:29:05 +00:00
|
|
|
"""Test config init."""
|
2017-02-14 05:34:36 +00:00
|
|
|
import asyncio
|
|
|
|
from unittest.mock import patch
|
|
|
|
|
|
|
|
from homeassistant.const import EVENT_COMPONENT_LOADED
|
2017-03-05 09:41:54 +00:00
|
|
|
from homeassistant.setup import async_setup_component, ATTR_COMPONENT
|
2017-02-14 05:34:36 +00:00
|
|
|
from homeassistant.components import config
|
2017-02-12 01:29:05 +00:00
|
|
|
|
2018-02-15 21:06:14 +00:00
|
|
|
from tests.common import mock_coro, mock_component
|
2017-02-12 01:29:05 +00:00
|
|
|
|
|
|
|
|
2017-02-14 05:34:36 +00:00
|
|
|
@asyncio.coroutine
|
2017-02-12 01:29:05 +00:00
|
|
|
def test_config_setup(hass, loop):
|
|
|
|
"""Test it sets up hassbian."""
|
2019-07-31 19:25:30 +00:00
|
|
|
yield from async_setup_component(hass, "config", {})
|
|
|
|
assert "config" in hass.config.components
|
2017-02-14 05:34:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
@asyncio.coroutine
|
2018-03-15 20:49:49 +00:00
|
|
|
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"]
|
|
|
|
), patch("homeassistant.components.config.zwave.async_setup") as stp:
|
2017-02-16 07:19:34 +00:00
|
|
|
stp.return_value = mock_coro(True)
|
2017-02-14 05:34:36 +00:00
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
yield from async_setup_component(hass, "config", {})
|
2017-02-14 05:34:36 +00:00
|
|
|
|
|
|
|
yield from hass.async_block_till_done()
|
|
|
|
assert stp.called
|
|
|
|
|
|
|
|
|
|
|
|
@asyncio.coroutine
|
2018-03-15 20:49:49 +00:00
|
|
|
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"]
|
|
|
|
):
|
|
|
|
yield from 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
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
with patch("homeassistant.components.config.zwave.async_setup") as stp:
|
2017-02-16 07:19:34 +00:00
|
|
|
stp.return_value = mock_coro(True)
|
2019-07-31 19:25:30 +00:00
|
|
|
hass.bus.async_fire(EVENT_COMPONENT_LOADED, {ATTR_COMPONENT: "zwave"})
|
2017-02-14 05:34:36 +00:00
|
|
|
yield from hass.async_block_till_done()
|
|
|
|
|
|
|
|
assert stp.called
|