Handle an unsupported device in the Broadlink config flow (#40242)
This commit is contained in:
1 parent
57b7ed6a07
commit
1eb8035122
5 files changed
+62
-1
No files matched your search
@@ -56,6 +56,16 @@ BROADLINK_DEVICES = {
|
||||
20025,
|
||||
5,
|
||||
),
|
||||
"Kitchen": ( # Not supported.
|
||||
"192.168.0.64",
|
||||
"34ea34b61d2c",
|
||||
"LB1",
|
||||
"Broadlink",
|
||||
"SmartBulb",
|
||||
0x504E,
|
||||
57,
|
||||
5,
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -172,6 +172,25 @@ async def test_flow_user_device_not_found(hass):
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_flow_user_device_not_supported(hass):
|
||||
"""Test we handle a device not supported in the user step."""
|
||||
device = get_device("Kitchen")
|
||||
mock_api = device.get_mock_api()
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
with patch(DEVICE_DISCOVERY, return_value=[mock_api]):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"host": device.host},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["reason"] == "not_supported"
|
||||
|
||||
|
||||
async def test_flow_user_network_unreachable(hass):
|
||||
"""Test we handle a network unreachable in the user step."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -631,6 +650,22 @@ async def test_flow_import_device_not_found(hass):
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
async def test_flow_import_device_not_supported(hass):
|
||||
"""Test we handle a device not supported in the import step."""
|
||||
device = get_device("Kitchen")
|
||||
mock_api = device.get_mock_api()
|
||||
|
||||
with patch(DEVICE_DISCOVERY, return_value=[mock_api]):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_IMPORT},
|
||||
data={"host": device.host},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["reason"] == "not_supported"
|
||||
|
||||
|
||||
async def test_flow_import_invalid_ip_address(hass):
|
||||
"""Test we handle an invalid IP address in the import step."""
|
||||
with patch("broadlink.discover", side_effect=OSError(errno.EINVAL, None)):
|
||||
|
||||
Reference in new issue
Block a user