Migrate config tests from coroutine to async/await (#30366)

This commit is contained in:
Franck Nijhof authored and Andrew Sayre committed 2020-01-01 17:16:27 -06:00
1 parent 4e7b35355d
commit 320dc52bb3
5 files changed
+133 -188

No files matched your search

+8 -12
View File
@@ -1,5 +1,4 @@
"""Test config init."""
import asyncio
from unittest.mock import patch
from homeassistant.components import config
@@ -9,15 +8,13 @@ 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):
async def test_config_setup(hass, loop):
"""Test it sets up hassbian."""
yield from async_setup_component(hass, "config", {})
await async_setup_component(hass, "config", {})
assert "config" in hass.config.components
@asyncio.coroutine
def test_load_on_demand_already_loaded(hass, aiohttp_client):
async def test_load_on_demand_already_loaded(hass, aiohttp_client):
"""Test getting suites."""
mock_component(hass, "zwave")
@@ -26,25 +23,24 @@ def test_load_on_demand_already_loaded(hass, aiohttp_client):
), patch("homeassistant.components.config.zwave.async_setup") as stp:
stp.return_value = mock_coro(True)
yield from async_setup_component(hass, "config", {})
await async_setup_component(hass, "config", {})
yield from hass.async_block_till_done()
await hass.async_block_till_done()
assert stp.called
@asyncio.coroutine
def test_load_on_demand_on_load(hass, aiohttp_client):
async def test_load_on_demand_on_load(hass, aiohttp_client):
"""Test getting suites."""
with patch.object(config, "SECTIONS", []), patch.object(
config, "ON_DEMAND", ["zwave"]
):
yield from async_setup_component(hass, "config", {})
await async_setup_component(hass, "config", {})
assert "config.zwave" not in hass.config.components
with patch("homeassistant.components.config.zwave.async_setup") as stp:
stp.return_value = mock_coro(True)
hass.bus.async_fire(EVENT_COMPONENT_LOADED, {ATTR_COMPONENT: "zwave"})
yield from hass.async_block_till_done()
await hass.async_block_till_done()
assert stp.called