mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 15:47:12 +00:00
Sonos remove unneeded mocking from test (#147064)
This commit is contained in:
parent
79683c8267
commit
be7735964b
@ -1,7 +1,6 @@
|
|||||||
"""Tests for the Sonos config flow."""
|
"""Tests for the Sonos config flow."""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from datetime import timedelta
|
|
||||||
import logging
|
import logging
|
||||||
from unittest.mock import Mock, PropertyMock, patch
|
from unittest.mock import Mock, PropertyMock, patch
|
||||||
|
|
||||||
@ -330,29 +329,24 @@ async def test_async_poll_manual_hosts_5(
|
|||||||
soco_2.renderingControl = Mock()
|
soco_2.renderingControl = Mock()
|
||||||
soco_2.renderingControl.GetVolume = Mock()
|
soco_2.renderingControl.GetVolume = Mock()
|
||||||
speaker_2_activity = SpeakerActivity(hass, soco_2)
|
speaker_2_activity = SpeakerActivity(hass, soco_2)
|
||||||
with patch(
|
|
||||||
"homeassistant.components.sonos.DISCOVERY_INTERVAL"
|
|
||||||
) as mock_discovery_interval:
|
|
||||||
# Speed up manual discovery interval so second iteration runs sooner
|
|
||||||
mock_discovery_interval.total_seconds = Mock(side_effect=[0.5, 60])
|
|
||||||
|
|
||||||
with caplog.at_level(logging.DEBUG):
|
with caplog.at_level(logging.DEBUG):
|
||||||
caplog.clear()
|
caplog.clear()
|
||||||
|
|
||||||
await _setup_hass(hass)
|
await _setup_hass(hass)
|
||||||
|
|
||||||
assert "media_player.bedroom" in entity_registry.entities
|
assert "media_player.bedroom" in entity_registry.entities
|
||||||
assert "media_player.living_room" in entity_registry.entities
|
assert "media_player.living_room" in entity_registry.entities
|
||||||
|
|
||||||
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=0.5))
|
async_fire_time_changed(hass, dt_util.utcnow() + DISCOVERY_INTERVAL)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await asyncio.gather(
|
await asyncio.gather(
|
||||||
*[speaker_1_activity.event.wait(), speaker_2_activity.event.wait()]
|
*[speaker_1_activity.event.wait(), speaker_2_activity.event.wait()]
|
||||||
)
|
)
|
||||||
assert speaker_1_activity.call_count == 1
|
assert speaker_1_activity.call_count == 1
|
||||||
assert speaker_2_activity.call_count == 1
|
assert speaker_2_activity.call_count == 1
|
||||||
assert "Activity on Living Room" in caplog.text
|
assert "Activity on Living Room" in caplog.text
|
||||||
assert "Activity on Bedroom" in caplog.text
|
assert "Activity on Bedroom" in caplog.text
|
||||||
|
|
||||||
await hass.async_block_till_done(wait_background_tasks=True)
|
await hass.async_block_till_done(wait_background_tasks=True)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user