core/tests/components/config/test_init.py

51 lines
1.5 KiB
Python
Raw Normal View History

"""Test config init."""
import asyncio
from unittest.mock import patch
from homeassistant.const import EVENT_COMPONENT_LOADED
from homeassistant.setup import async_setup_component, ATTR_COMPONENT
from homeassistant.components import config
from tests.common import mock_coro, mock_component
@asyncio.coroutine
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
@asyncio.coroutine
def test_load_on_demand_already_loaded(hass, aiohttp_client):
"""Test getting suites."""
2019-07-31 19:25:30 +00:00
mock_component(hass, "zwave")
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)
2019-07-31 19:25:30 +00:00
yield from async_setup_component(hass, "config", {})
yield from hass.async_block_till_done()
assert stp.called
@asyncio.coroutine
def test_load_on_demand_on_load(hass, aiohttp_client):
"""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", {})
2019-07-31 19:25:30 +00:00
assert "config.zwave" not in hass.config.components
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"})
yield from hass.async_block_till_done()
assert stp.called