Websocket media browsing for Plex (#35590)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
8 files changed
+323
-17
No files matched your search
@@ -100,3 +100,60 @@ def test_deprecated_base_class(caplog):
|
||||
|
||||
CustomMediaPlayer()
|
||||
assert "MediaPlayerDevice is deprecated, modify CustomMediaPlayer" in caplog.text
|
||||
|
||||
|
||||
async def test_media_browse(hass, hass_ws_client):
|
||||
"""Test browsing media."""
|
||||
await async_setup_component(
|
||||
hass, "media_player", {"media_player": {"platform": "demo"}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
client = await hass_ws_client(hass)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.demo.media_player.YOUTUBE_PLAYER_SUPPORT",
|
||||
media_player.SUPPORT_BROWSE_MEDIA,
|
||||
), patch(
|
||||
"homeassistant.components.media_player.MediaPlayerEntity." "async_browse_media",
|
||||
return_value={"bla": "yo"},
|
||||
) as mock_browse_media:
|
||||
await client.send_json(
|
||||
{
|
||||
"id": 5,
|
||||
"type": "media_player/browse_media",
|
||||
"entity_id": "media_player.bedroom",
|
||||
"media_content_type": "album",
|
||||
"media_content_id": "abcd",
|
||||
}
|
||||
)
|
||||
|
||||
msg = await client.receive_json()
|
||||
|
||||
assert msg["id"] == 5
|
||||
assert msg["type"] == TYPE_RESULT
|
||||
assert msg["success"]
|
||||
assert msg["result"] == {"bla": "yo"}
|
||||
assert mock_browse_media.mock_calls[0][1] == ("album", "abcd")
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.demo.media_player.YOUTUBE_PLAYER_SUPPORT",
|
||||
media_player.SUPPORT_BROWSE_MEDIA,
|
||||
), patch(
|
||||
"homeassistant.components.media_player.MediaPlayerEntity." "async_browse_media",
|
||||
return_value={"bla": "yo"},
|
||||
):
|
||||
await client.send_json(
|
||||
{
|
||||
"id": 6,
|
||||
"type": "media_player/browse_media",
|
||||
"entity_id": "media_player.bedroom",
|
||||
}
|
||||
)
|
||||
|
||||
msg = await client.receive_json()
|
||||
|
||||
assert msg["id"] == 6
|
||||
assert msg["type"] == TYPE_RESULT
|
||||
assert msg["success"]
|
||||
assert msg["result"] == {"bla": "yo"}
|
||||
Reference in new issue
Block a user