hass-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.components import config
from homeassistant.const import EVENT_COMPONENT_LOADED
from homeassistant.setup import ATTR_COMPONENT, async_setup_component
from tests.common import mock_component, mock_coro
@asyncio.coroutine
def test_config_setup(hass, loop):
"""Test it sets up hassbian."""
2019-07-31 12:25:30 -07: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 12:25:30 -07:00
mock_component(hass, "zwave")
2019-07-31 12:25:30 -07:00
with patch.object(config, "SECTIONS", []), patch.object(
config, "ON_DEMAND", ["zwave"]
), patch("homeassistant.components.config.zwave.async_setup") as stp:
2017-02-15 23:19:34 -08:00
stp.return_value = mock_coro(True)
2019-07-31 12:25:30 -07: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 12:25:30 -07:00
with patch.object(config, "SECTIONS", []), patch.object(
config, "ON_DEMAND", ["zwave"]
):
yield from async_setup_component(hass, "config", {})
2019-07-31 12:25:30 -07:00
assert "config.zwave" not in hass.config.components
2019-07-31 12:25:30 -07:00
with patch("homeassistant.components.config.zwave.async_setup") as stp:
2017-02-15 23:19:34 -08:00
stp.return_value = mock_coro(True)
2019-07-31 12:25:30 -07:00
hass.bus.async_fire(EVENT_COMPONENT_LOADED, {ATTR_COMPONENT: "zwave"})
yield from hass.async_block_till_done()
assert stp.called