Fix lookup by Plex media key when playing on Sonos (#38119)
This commit is contained in:
parent
364aaceb1c
commit
67312e2d42
2 changed files with 25 additions and 3 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue