Allow fetching media player covers via websocket connection (#14233)
Lint
This commit is contained in:
parent
58257af289
commit
15e75b07d8
2 changed files with 85 additions and 1 deletions
37
tests/components/media_player/test_init.py
Normal file
37
tests/components/media_player/test_init.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
"""Test the base functions of the media player."""
|
||||
import base64
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.components import websocket_api
|
||||
|
||||
from tests.common import mock_coro
|
||||
|
||||
|
||||
async def test_get_panels(hass, hass_ws_client):
|
||||
"""Test get_panels command."""
|
||||
await async_setup_component(hass, 'media_player', {
|
||||
'media_player': {
|
||||
'platform': 'demo'
|
||||
}
|
||||
})
|
||||
|
||||
client = await hass_ws_client(hass)
|
||||
|
||||
with patch('homeassistant.components.media_player.MediaPlayerDevice.'
|
||||
'async_get_media_image', return_value=mock_coro(
|
||||
(b'image', 'image/jpeg'))):
|
||||
await client.send_json({
|
||||
'id': 5,
|
||||
'type': 'media_player_thumbnail',
|
||||
'entity_id': 'media_player.bedroom',
|
||||
})
|
||||
|
||||
msg = await client.receive_json()
|
||||
|
||||
assert msg['id'] == 5
|
||||
assert msg['type'] == websocket_api.TYPE_RESULT
|
||||
assert msg['success']
|
||||
assert msg['result']['content_type'] == 'image/jpeg'
|
||||
assert msg['result']['content'] == \
|
||||
base64.b64encode(b'image').decode('utf-8')
|
Loading…
Add table
Add a link
Reference in a new issue