Check if Multi-PAN addon is using the HA Yellow's radio (#82853)

This commit is contained in:
Erik Montnemery 2022-11-28 19:55:07 +01:00 committed by GitHub
parent 58b3a00b16
commit 892be99ca0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 80 additions and 14 deletions

View file

@ -110,6 +110,8 @@ async def test_setup_zha_multipan(
"""Test zha gets the right config."""
mock_integration(hass, MockModule("hassio"))
addon_info.return_value["options"]["device"] = "/dev/ttyAMA1"
# Setup the config entry
config_entry = MockConfigEntry(
data={},
@ -152,6 +154,56 @@ async def test_setup_zha_multipan(
assert config_entry.title == "Yellow Multi-PAN"
async def test_setup_zha_multipan_other_device(
hass: HomeAssistant, addon_info, addon_running
) -> None:
"""Test zha gets the right config."""
mock_integration(hass, MockModule("hassio"))
addon_info.return_value["options"]["device"] = "/dev/not_yellow_radio"
# Setup the config entry
config_entry = MockConfigEntry(
data={},
domain=DOMAIN,
options={},
title="Home Assistant Yellow",
)
config_entry.add_to_hass(hass)
with patch(
"homeassistant.components.homeassistant_yellow.get_os_info",
return_value={"board": "yellow"},
) as mock_get_os_info, patch(
"homeassistant.components.onboarding.async_is_onboarded", return_value=False
):
assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
assert len(mock_get_os_info.mock_calls) == 1
# Finish setting up ZHA
zha_flows = hass.config_entries.flow.async_progress_by_handler("zha")
assert len(zha_flows) == 1
assert zha_flows[0]["step_id"] == "choose_formation_strategy"
await hass.config_entries.flow.async_configure(
zha_flows[0]["flow_id"],
user_input={"next_step_id": zha.config_flow.FORMATION_REUSE_SETTINGS},
)
await hass.async_block_till_done()
config_entry = hass.config_entries.async_entries("zha")[0]
assert config_entry.data == {
"device": {
"baudrate": 115200,
"flow_control": "hardware",
"path": "/dev/ttyAMA1",
},
"radio_type": "ezsp",
}
assert config_entry.options == {}
assert config_entry.title == "Yellow"
async def test_setup_entry_wrong_board(hass: HomeAssistant) -> None:
"""Test setup of a config entry with wrong board type."""
mock_integration(hass, MockModule("hassio"))