mirror of
https://github.com/home-assistant/core.git
synced 2026-05-08 09:38:58 +01:00
Add move queue item HEOS entity service (#142301)
This commit is contained in:
@@ -39,6 +39,7 @@ class MockHeos(Heos):
|
||||
self.player_clear_queue: AsyncMock = AsyncMock()
|
||||
self.player_get_queue: AsyncMock = AsyncMock()
|
||||
self.player_get_quick_selects: AsyncMock = AsyncMock()
|
||||
self.player_move_queue_item: AsyncMock = AsyncMock()
|
||||
self.player_play_next: AsyncMock = AsyncMock()
|
||||
self.player_play_previous: AsyncMock = AsyncMock()
|
||||
self.player_play_queue: AsyncMock = AsyncMock()
|
||||
|
||||
@@ -27,12 +27,14 @@ from syrupy.assertion import SnapshotAssertion
|
||||
from syrupy.filters import props
|
||||
|
||||
from homeassistant.components.heos.const import (
|
||||
ATTR_DESTINATION_POSITION,
|
||||
ATTR_QUEUE_IDS,
|
||||
DOMAIN,
|
||||
SERVICE_GET_QUEUE,
|
||||
SERVICE_GROUP_VOLUME_DOWN,
|
||||
SERVICE_GROUP_VOLUME_SET,
|
||||
SERVICE_GROUP_VOLUME_UP,
|
||||
SERVICE_MOVE_QUEUE_ITEM,
|
||||
SERVICE_REMOVE_FROM_QUEUE,
|
||||
)
|
||||
from homeassistant.components.media_player import (
|
||||
@@ -1784,3 +1786,45 @@ async def test_remove_from_queue(
|
||||
blocking=True,
|
||||
)
|
||||
controller.player_remove_from_queue.assert_called_once_with(1, [1, 2])
|
||||
|
||||
|
||||
async def test_move_queue_item_queue(
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, controller: MockHeos
|
||||
) -> None:
|
||||
"""Test the move queue service."""
|
||||
config_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_MOVE_QUEUE_ITEM,
|
||||
{
|
||||
ATTR_ENTITY_ID: "media_player.test_player",
|
||||
ATTR_QUEUE_IDS: [1, "2"],
|
||||
ATTR_DESTINATION_POSITION: 10,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
controller.player_move_queue_item.assert_called_once_with(1, [1, 2], 10)
|
||||
|
||||
|
||||
async def test_move_queue_item_queue_error_raises(
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, controller: MockHeos
|
||||
) -> None:
|
||||
"""Test move queue raises error when failed."""
|
||||
config_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
controller.player_move_queue_item.side_effect = HeosError("error")
|
||||
with pytest.raises(
|
||||
HomeAssistantError,
|
||||
match=re.escape("Unable to move queue item: error"),
|
||||
):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_MOVE_QUEUE_ITEM,
|
||||
{
|
||||
ATTR_ENTITY_ID: "media_player.test_player",
|
||||
ATTR_QUEUE_IDS: [1, "2"],
|
||||
ATTR_DESTINATION_POSITION: 10,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user