1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-08 09:38:58 +01:00

Add Get Queue HEOS entity service (#141150)

This commit is contained in:
Andrew Sayre
2025-03-25 16:55:44 -05:00
committed by GitHub
parent f3bcb96b41
commit ab709aeb46
9 changed files with 120 additions and 8 deletions
+1
View File
@@ -37,6 +37,7 @@ class MockHeos(Heos):
self.play_preset_station: AsyncMock = AsyncMock()
self.play_url: AsyncMock = AsyncMock()
self.player_clear_queue: AsyncMock = AsyncMock()
self.player_get_queue: AsyncMock = AsyncMock()
self.player_get_quick_selects: AsyncMock = AsyncMock()
self.player_play_next: AsyncMock = AsyncMock()
self.player_play_previous: AsyncMock = AsyncMock()
+26
View File
@@ -20,6 +20,7 @@ from pyheos import (
NetworkType,
PlayerUpdateResult,
PlayState,
QueueItem,
RepeatType,
const,
)
@@ -359,3 +360,28 @@ def change_data_fixture() -> PlayerUpdateResult:
def change_data_mapped_ids_fixture() -> PlayerUpdateResult:
"""Create player change data for testing."""
return PlayerUpdateResult(updated_player_ids={1: 101})
@pytest.fixture(name="queue")
def queue_fixture() -> list[QueueItem]:
"""Create a queue fixture."""
return [
QueueItem(
queue_id=1,
song="Espresso",
album="Espresso",
artist="Sabrina Carpenter",
image_url="http://resources.wimpmusic.com/images/e4f2d75f/a69e/4b8a/b800/e18546b1ad4c/640x640.jpg",
media_id="356276483",
album_id="356276481",
),
QueueItem(
queue_id=2,
song="A Bar Song (Tipsy)",
album="A Bar Song (Tipsy)",
artist="Shaboozey",
image_url="http://resources.wimpmusic.com/images/d05b8da3/4fae/45ff/ac1b/7ab7caab3523/640x640.jpg",
media_id="354365598",
album_id="354365596",
),
]
@@ -159,6 +159,32 @@
'title': 'Music Sources',
})
# ---
# name: test_get_queue
dict({
'media_player.test_player': dict({
'queue': list([
dict({
'album': 'Espresso',
'album_id': '356276481',
'artist': 'Sabrina Carpenter',
'image_url': 'http://resources.wimpmusic.com/images/e4f2d75f/a69e/4b8a/b800/e18546b1ad4c/640x640.jpg',
'media_id': '356276483',
'queue_id': 1,
'song': 'Espresso',
}),
dict({
'album': 'A Bar Song (Tipsy)',
'album_id': '354365596',
'artist': 'Shaboozey',
'image_url': 'http://resources.wimpmusic.com/images/d05b8da3/4fae/45ff/ac1b/7ab7caab3523/640x640.jpg',
'media_id': '354365598',
'queue_id': 2,
'song': 'A Bar Song (Tipsy)',
}),
]),
}),
})
# ---
# name: test_state_attributes
StateSnapshot({
'attributes': ReadOnlyDict({
@@ -15,6 +15,7 @@ from pyheos import (
MediaType as HeosMediaType,
PlayerUpdateResult,
PlayState,
QueueItem,
RepeatType,
SignalHeosEvent,
SignalType,
@@ -27,6 +28,7 @@ from syrupy.filters import props
from homeassistant.components.heos.const import (
DOMAIN,
SERVICE_GET_QUEUE,
SERVICE_GROUP_VOLUME_DOWN,
SERVICE_GROUP_VOLUME_SET,
SERVICE_GROUP_VOLUME_UP,
@@ -1696,3 +1698,27 @@ async def test_media_player_group_fails_wrong_integration(
blocking=True,
)
controller.set_group.assert_not_called()
async def test_get_queue(
hass: HomeAssistant,
config_entry: MockConfigEntry,
controller: MockHeos,
queue: list[QueueItem],
snapshot: SnapshotAssertion,
) -> None:
"""Test the get queue service."""
config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(config_entry.entry_id)
controller.player_get_queue.return_value = queue
response = await hass.services.async_call(
DOMAIN,
SERVICE_GET_QUEUE,
{
ATTR_ENTITY_ID: "media_player.test_player",
},
blocking=True,
return_response=True,
)
controller.player_get_queue.assert_called_once_with(1, None, None)
assert response == snapshot