2022-06-14 06:25:11 +00:00
|
|
|
"""Test fixtures for the Home Assistant Yellow integration."""
|
2022-08-31 15:21:37 +00:00
|
|
|
from collections.abc import Generator
|
|
|
|
from typing import Any
|
|
|
|
from unittest.mock import MagicMock, patch
|
2022-06-14 06:25:11 +00:00
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
2022-08-31 15:21:37 +00:00
|
|
|
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 = []
|
|
|
|
|
2022-06-14 06:25:11 +00:00
|
|
|
with patch(
|
2022-08-31 15:21:37 +00:00
|
|
|
"bellows.zigbee.application.ControllerApplication.probe", side_effect=mock_probe
|
|
|
|
), patch(
|
|
|
|
"homeassistant.components.zha.config_flow.BaseZhaFlow._connect_zigpy_app",
|
|
|
|
return_value=mock_connect_app,
|
|
|
|
), patch(
|
2022-06-14 06:25:11 +00:00
|
|
|
"homeassistant.components.zha.async_setup_entry",
|
|
|
|
return_value=True,
|
|
|
|
):
|
|
|
|
yield
|