Add test coverage for WiZ lights and switches (#66387)

This commit is contained in:
J. Nick Koston 2022-02-14 09:31:26 -06:00 committed by GitHub
parent 4522a5698c
commit 445ad1d592
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 288 additions and 43 deletions

View file

@ -410,6 +410,27 @@ async def test_setup_via_discovery_cannot_connect(hass):
assert result3["reason"] == "cannot_connect"
async def test_setup_via_discovery_exception_finds_nothing(hass):
"""Test we do not find anything if discovery throws."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
await hass.async_block_till_done()
assert result["type"] == "form"
assert result["step_id"] == "user"
assert not result["errors"]
with patch(
"homeassistant.components.wiz.discovery.find_wizlights",
side_effect=OSError,
):
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done()
assert result2["type"] == RESULT_TYPE_ABORT
assert result2["reason"] == "no_devices_found"
async def test_discovery_with_firmware_update(hass):
"""Test we check the device again between first discovery and config entry creation."""
with _patch_wizlight(