Ensure yeelight can be unloaded when device is offline (#56464)

This commit is contained in:
J. Nick Koston 2021-09-26 11:54:43 -05:00 committed by GitHub
parent 26f73779cc
commit 52410ff0d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 9 deletions

View file

@ -366,6 +366,26 @@ async def test_async_listen_error_late_discovery(hass, caplog):
assert config_entry.options[CONF_MODEL] == MODEL
async def test_unload_before_discovery(hass, caplog):
"""Test unloading before discovery."""
config_entry = MockConfigEntry(domain=DOMAIN, data=CONFIG_ENTRY_DATA)
config_entry.add_to_hass(hass)
mocked_bulb = _mocked_bulb(cannot_connect=True)
with _patch_discovery(no_device=True), patch(
f"{MODULE}.AsyncBulb", return_value=mocked_bulb
):
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
assert config_entry.state is ConfigEntryState.LOADED
await hass.config_entries.async_unload(config_entry.entry_id)
await hass.async_block_till_done()
assert config_entry.state is ConfigEntryState.NOT_LOADED
async def test_async_listen_error_has_host_with_id(hass: HomeAssistant):
"""Test the async listen error."""
config_entry = MockConfigEntry(