Rename MediaPlayerDevice to MediaPlayerEntity (#34592)

This commit is contained in:
Erik Montnemery authored and GitHub committed 2020-04-25 18:00:57 +02:00
1 parent 56f7c3b55c
commit 62bc02fdda
75 files changed
+178 -156

No files matched your search

@@ -14,7 +14,7 @@ from homeassistant.const import (
from tests.common import get_test_home_assistant
class AsyncMediaPlayer(mp.MediaPlayerDevice):
class AsyncMediaPlayer(mp.MediaPlayerEntity):
"""Async media player test class."""
def __init__(self, hass):
@@ -65,7 +65,7 @@ class AsyncMediaPlayer(mp.MediaPlayerDevice):
self._state = STATE_OFF
class SyncMediaPlayer(mp.MediaPlayerDevice):
class SyncMediaPlayer(mp.MediaPlayerEntity):
"""Sync media player test class."""
def __init__(self, hass):
+15 -4
View File
@@ -3,6 +3,7 @@ import base64
from asynctest import patch
from homeassistant.components import media_player
from homeassistant.components.websocket_api.const import TYPE_RESULT
from homeassistant.setup import async_setup_component
@@ -18,7 +19,7 @@ async def test_get_image(hass, hass_ws_client, caplog):
client = await hass_ws_client(hass)
with patch(
"homeassistant.components.media_player.MediaPlayerDevice."
"homeassistant.components.media_player.MediaPlayerEntity."
"async_get_media_image",
return_value=mock_coro((b"image", "image/jpeg")),
):
@@ -53,7 +54,7 @@ async def test_get_image_http(hass, aiohttp_client):
client = await aiohttp_client(hass.http.app)
with patch(
"homeassistant.components.media_player.MediaPlayerDevice."
"homeassistant.components.media_player.MediaPlayerEntity."
"async_get_media_image",
return_value=(b"image", "image/jpeg"),
):
@@ -66,7 +67,7 @@ async def test_get_image_http(hass, aiohttp_client):
async def test_get_image_http_remote(hass, aiohttp_client):
"""Test get image url via http command."""
with patch(
"homeassistant.components.media_player.MediaPlayerDevice."
"homeassistant.components.media_player.MediaPlayerEntity."
"media_image_remotely_accessible",
return_value=True,
):
@@ -80,7 +81,7 @@ async def test_get_image_http_remote(hass, aiohttp_client):
client = await aiohttp_client(hass.http.app)
with patch(
"homeassistant.components.media_player.MediaPlayerDevice."
"homeassistant.components.media_player.MediaPlayerEntity."
"async_get_media_image",
return_value=(b"image", "image/jpeg"),
):
@@ -88,3 +89,13 @@ async def test_get_image_http_remote(hass, aiohttp_client):
content = await resp.read()
assert content == b"image"
def test_deprecated_base_class(caplog):
"""Test deprecated base class."""
class CustomMediaPlayer(media_player.MediaPlayerDevice):
pass
CustomMediaPlayer()
assert "MediaPlayerDevice is deprecated, modify CustomMediaPlayer" in caplog.text
@@ -22,7 +22,7 @@ def validate_config(config):
return validated_config
class MockMediaPlayer(media_player.MediaPlayerDevice):
class MockMediaPlayer(media_player.MediaPlayerEntity):
"""Mock media player for testing."""
def __init__(self, hass, name):