Add multi-zone support to Anthem AV receiver and distribution solution (#74779)
* Add multi-zone support to Anthem AV receiver and distribution amplifier * Fix typo in comment * Convert properties to attribute and add test * Migrate entity name * Fix after rebase add strict typing and bump version * fix typing * Simplify test * Small improvement * remove dispatcher send and use callback
This commit is contained in:
parent
8181da7090
commit
ace359b1bd
12 changed files with 200 additions and 104 deletions
|
@ -1,10 +1,12 @@
|
|||
"""Fixtures for anthemav integration tests."""
|
||||
from typing import Callable
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.anthemav.const import CONF_MODEL, DOMAIN
|
||||
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME, CONF_PORT
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -16,17 +18,25 @@ def mock_anthemav() -> AsyncMock:
|
|||
avr.protocol.macaddress = "000000000001"
|
||||
avr.protocol.model = "MRX 520"
|
||||
avr.reconnect = AsyncMock()
|
||||
avr.protocol.wait_for_device_initialised = AsyncMock()
|
||||
avr.close = MagicMock()
|
||||
avr.protocol.input_list = []
|
||||
avr.protocol.audio_listening_mode_list = []
|
||||
avr.protocol.power = False
|
||||
avr.protocol.zones = {1: get_zone(), 2: get_zone()}
|
||||
return avr
|
||||
|
||||
|
||||
def get_zone() -> MagicMock:
|
||||
"""Return a mocked zone."""
|
||||
zone = MagicMock()
|
||||
|
||||
zone.power = False
|
||||
return zone
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_connection_create(mock_anthemav: AsyncMock) -> AsyncMock:
|
||||
"""Return the default mocked connection.create."""
|
||||
|
||||
with patch(
|
||||
"anthemav.Connection.create",
|
||||
return_value=mock_anthemav,
|
||||
|
@ -34,6 +44,12 @@ def mock_connection_create(mock_anthemav: AsyncMock) -> AsyncMock:
|
|||
yield mock
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def update_callback(mock_connection_create: AsyncMock) -> Callable[[str], None]:
|
||||
"""Return the update_callback used when creating the connection."""
|
||||
return mock_connection_create.call_args[1]["update_callback"]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_config_entry() -> MockConfigEntry:
|
||||
"""Return the default mocked config entry."""
|
||||
|
@ -48,3 +64,18 @@ def mock_config_entry() -> MockConfigEntry:
|
|||
},
|
||||
unique_id="00:00:00:00:00:01",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def init_integration(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_connection_create: AsyncMock,
|
||||
) -> MockConfigEntry:
|
||||
"""Set up the AnthemAv integration for testing."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
return mock_config_entry
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue