1
mirror of https://github.com/home-assistant/core synced 2024-08-06 09:34:49 +02:00

Convert device_sun_light_trigger test fixture to async (#89578)

This commit is contained in:
Erik Montnemery 2023-03-12 14:48:46 +01:00 committed by GitHub
parent 234610b1cc
commit 376a6eb82a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 13 deletions

View File

@ -28,9 +28,11 @@ from tests.common import async_fire_time_changed
@pytest.fixture
def scanner(hass, enable_custom_integrations):
async def scanner(hass, enable_custom_integrations):
"""Initialize components."""
scanner = getattr(hass.components, "test.device_tracker").get_scanner(None, None)
scanner = await getattr(hass.components, "test.device_tracker").async_get_scanner(
None, None
)
scanner.reset()
scanner.come_home("DEV1")
@ -56,19 +58,16 @@ def scanner(hass, enable_custom_integrations):
},
},
):
assert hass.loop.run_until_complete(
async_setup_component(
hass,
device_tracker.DOMAIN,
{device_tracker.DOMAIN: {CONF_PLATFORM: "test"}},
)
assert await async_setup_component(
hass,
device_tracker.DOMAIN,
{device_tracker.DOMAIN: {CONF_PLATFORM: "test"}},
)
assert hass.loop.run_until_complete(
async_setup_component(
hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}}
)
assert await async_setup_component(
hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}}
)
await hass.async_block_till_done()
return scanner

View File

@ -5,7 +5,7 @@ from homeassistant.components.device_tracker.config_entry import ScannerEntity
from homeassistant.components.device_tracker.const import SOURCE_TYPE_ROUTER
def get_scanner(hass, config):
async def async_get_scanner(hass, config):
"""Return a mock scanner."""
return SCANNER