1
0
mirror of https://github.com/home-assistant/core.git synced 2026-06-30 11:16:05 +01:00
Files
core/tests/components/wiim/__init__.py
T
Linkplay2020 d9a89beb3d Bump wiim to 1.0.4 (#172334)
Co-authored-by: Tao Jiang <tao.jiang@linkplay.com>
2026-05-28 11:38:22 +02:00

44 lines
1.4 KiB
Python

"""Tests for the wiim integration."""
from unittest.mock import MagicMock
from wiim.consts import PlayingStatus
from homeassistant.core import HomeAssistant
from homeassistant.core_config import async_process_ha_core_config
from tests.common import MockConfigEntry
async def setup_integration(hass: HomeAssistant, config_entry: MockConfigEntry) -> None:
"""Set up the component."""
await async_process_ha_core_config(
hass,
{"internal_url": "http://192.168.1.10:8123"},
)
config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
async def fire_general_update(hass: HomeAssistant, mock_device: MagicMock) -> None:
"""Trigger the registered general update callback on the mock device."""
assert mock_device.general_event_callback is not None
mock_device.general_event_callback(mock_device)
await hass.async_block_till_done()
async def fire_transport_update(
hass: HomeAssistant,
mock_device: MagicMock,
transport_state: PlayingStatus,
) -> None:
"""Trigger the registered AVTransport callback on the mock device."""
assert mock_device.av_transport_event_callback is not None
mock_device.event_data = {"TransportState": transport_state.value}
mock_device.playing_status = transport_state
mock_device.av_transport_event_callback(MagicMock(), [])
await hass.async_block_till_done()