mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Fix lookup by Plex media key when playing on Sonos (#38119)
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
"""Tests for Plex player playback methods/services."""
|
||||
from plexapi.exceptions import NotFound
|
||||
|
||||
from homeassistant.components.media_player.const import (
|
||||
ATTR_MEDIA_CONTENT_ID,
|
||||
ATTR_MEDIA_CONTENT_TYPE,
|
||||
@@ -52,7 +54,7 @@ async def test_sonos_playback(hass):
|
||||
True,
|
||||
)
|
||||
|
||||
# Test success with dict
|
||||
# Test success with plex_key
|
||||
with patch.object(
|
||||
hass.components.sonos,
|
||||
"get_coordinator_name",
|
||||
@@ -69,7 +71,7 @@ async def test_sonos_playback(hass):
|
||||
True,
|
||||
)
|
||||
|
||||
# Test success with plex_key
|
||||
# Test success with dict
|
||||
with patch.object(
|
||||
hass.components.sonos,
|
||||
"get_coordinator_name",
|
||||
@@ -86,6 +88,23 @@ async def test_sonos_playback(hass):
|
||||
True,
|
||||
)
|
||||
|
||||
# Test media lookup failure
|
||||
with patch.object(
|
||||
hass.components.sonos,
|
||||
"get_coordinator_name",
|
||||
return_value="media_player.sonos_kitchen",
|
||||
), patch.object(mock_plex_server, "fetchItem", side_effect=NotFound):
|
||||
assert await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_PLAY_ON_SONOS,
|
||||
{
|
||||
ATTR_ENTITY_ID: "media_player.sonos_kitchen",
|
||||
ATTR_MEDIA_CONTENT_TYPE: MEDIA_TYPE_MUSIC,
|
||||
ATTR_MEDIA_CONTENT_ID: "999",
|
||||
},
|
||||
True,
|
||||
)
|
||||
|
||||
# Test invalid Plex server requested
|
||||
with patch.object(
|
||||
hass.components.sonos,
|
||||
|
||||
Reference in New Issue
Block a user