Migrate ZHA when enabling multi-PAN support on HA Yellow (#82213)

* Migrate ZHA when enabling multi-PAN support on HA Yellow

* Refactor BaseZhaFlow.async_step_maybe_confirm_ezsp_restore

* Change data passed to ZHA to initiate migration

* Catch errors during ZHA migration

* Fix ZhaMigrationHelper.async_prepare_yellow_migration return value

* Improve test coverage

* Improve test coverage

* Fix spelling

* Rename some none HA yellow specifics

* Rename again

* Increase number of migration retries + refactor

* Suppress OperationNotAllowed when reloading

* Adjust tests
This commit is contained in:
Erik Montnemery 2022-11-22 11:17:23 +01:00 committed by GitHub
parent 15176300e2
commit be7e76f302
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 1120 additions and 117 deletions

View file

@ -1,9 +1,37 @@
"""Test fixtures for the Home Assistant Hardware integration."""
from unittest.mock import patch
from collections.abc import Generator
from typing import Any
from unittest.mock import MagicMock, patch
import pytest
@pytest.fixture(autouse=True)
def mock_zha_config_flow_setup() -> Generator[None, None, None]:
"""Mock the radio connection and probing of the ZHA config flow."""
def mock_probe(config: dict[str, Any]) -> None:
# The radio probing will return the correct baudrate
return {**config, "baudrate": 115200}
mock_connect_app = MagicMock()
mock_connect_app.__aenter__.return_value.backups.backups = [MagicMock()]
mock_connect_app.__aenter__.return_value.backups.create_backup.return_value = (
MagicMock()
)
with patch(
"bellows.zigbee.application.ControllerApplication.probe", side_effect=mock_probe
), patch(
"homeassistant.components.zha.radio_manager.ZhaRadioManager._connect_zigpy_app",
return_value=mock_connect_app,
), patch(
"homeassistant.components.zha.async_setup_entry",
return_value=True,
):
yield
@pytest.fixture(name="addon_running")
def mock_addon_running(addon_store_info, addon_info):
"""Mock add-on already running."""