Improve sonos test synchronization (#114468)
This commit is contained in:
parent
3e99afdd54
commit
d63adb6350
2 changed files with 38 additions and 9 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
from unittest.mock import Mock
|
||||
|
||||
from soco import SoCo
|
||||
|
||||
from homeassistant.components.sonos.const import (
|
||||
DOMAIN,
|
||||
SCAN_INTERVAL,
|
||||
|
@ -11,27 +13,25 @@ from homeassistant.core import HomeAssistant
|
|||
from homeassistant.helpers.issue_registry import async_get as async_get_issue_registry
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from .conftest import SonosMockEvent
|
||||
from .conftest import SonosMockEvent, SonosMockSubscribe
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
|
||||
|
||||
async def test_subscription_repair_issues(
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, soco, zgs_discovery
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, soco: SoCo, zgs_discovery
|
||||
) -> None:
|
||||
"""Test repair issues handling for failed subscriptions."""
|
||||
issue_registry = async_get_issue_registry(hass)
|
||||
|
||||
subscription = soco.zoneGroupTopology.subscribe.return_value
|
||||
subscription: SonosMockSubscribe = soco.zoneGroupTopology.subscribe.return_value
|
||||
subscription.event_listener = Mock(address=("192.168.4.2", 1400))
|
||||
|
||||
config_entry.add_to_hass(hass)
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# Ensure an issue is registered on subscription failure
|
||||
sub_callback = subscription.callback
|
||||
sub_callback = await subscription.wait_for_callback_to_be_set()
|
||||
async_fire_time_changed(hass, dt_util.utcnow() + SCAN_INTERVAL)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
assert issue_registry.async_get_issue(DOMAIN, SUB_FAIL_ISSUE_ID)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue