From 31b806ced114256c923279f22b7625448e0a0309 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Thu, 17 Dec 2020 17:43:52 +0100 Subject: [PATCH] Revert "Change http to auto for cast media image url" (#44327) --- homeassistant/components/cast/media_player.py | 4 +- tests/components/cast/test_media_player.py | 44 ------------------- 2 files changed, 1 insertion(+), 47 deletions(-) diff --git a/homeassistant/components/cast/media_player.py b/homeassistant/components/cast/media_player.py index b76dbcaf20b..e68800efb44 100644 --- a/homeassistant/components/cast/media_player.py +++ b/homeassistant/components/cast/media_player.py @@ -665,9 +665,7 @@ class CastDevice(MediaPlayerEntity): images = media_status.images - return ( - images[0].url.replace("http://", "//") if images and images[0].url else None - ) + return images[0].url if images and images[0].url else None @property def media_image_remotely_accessible(self) -> bool: diff --git a/tests/components/cast/test_media_player.py b/tests/components/cast/test_media_player.py index 0e9f6c13e3d..4f75e93faef 100644 --- a/tests/components/cast/test_media_player.py +++ b/tests/components/cast/test_media_player.py @@ -787,50 +787,6 @@ async def test_entity_media_states(hass: HomeAssistantType): assert state.state == "unknown" -async def test_url_replace(hass: HomeAssistantType): - """Test functionality of replacing URL for HTTPS.""" - entity_id = "media_player.speaker" - reg = await hass.helpers.entity_registry.async_get_registry() - - info = get_fake_chromecast_info() - full_info = attr.evolve( - info, model_name="google home", friendly_name="Speaker", uuid=FakeUUID - ) - - chromecast = await async_setup_media_player_cast(hass, info) - _, conn_status_cb, media_status_cb = get_status_callbacks(chromecast) - - connection_status = MagicMock() - connection_status.status = "CONNECTED" - conn_status_cb(connection_status) - await hass.async_block_till_done() - - state = hass.states.get(entity_id) - assert state is not None - assert state.name == "Speaker" - assert state.state == "unknown" - assert entity_id == reg.async_get_entity_id("media_player", "cast", full_info.uuid) - - class FakeHTTPImage: - url = "http://example.com/test.png" - - class FakeHTTPSImage: - url = "https://example.com/test.png" - - media_status = MagicMock(images=[FakeHTTPImage()]) - media_status.player_is_playing = True - media_status_cb(media_status) - await hass.async_block_till_done() - state = hass.states.get(entity_id) - assert state.attributes.get("entity_picture") == "//example.com/test.png" - - media_status.images = [FakeHTTPSImage()] - media_status_cb(media_status) - await hass.async_block_till_done() - state = hass.states.get(entity_id) - assert state.attributes.get("entity_picture") == "https://example.com/test.png" - - async def test_group_media_states(hass, mz_mock): """Test media states are read from group if entity has no state.""" entity_id = "media_player.speaker"