From 1279592a98a3076998a478f062dabab8af2ad4d5 Mon Sep 17 00:00:00 2001 From: Robert Hillis Date: Tue, 21 Dec 2021 17:37:46 -0500 Subject: [PATCH] Remove deprecated yaml config from vlc_telnet (#62542) --- .../components/vlc_telnet/config_flow.py | 4 -- .../components/vlc_telnet/media_player.py | 45 ++----------------- .../components/vlc_telnet/test_config_flow.py | 37 +-------------- 3 files changed, 6 insertions(+), 80 deletions(-) diff --git a/homeassistant/components/vlc_telnet/config_flow.py b/homeassistant/components/vlc_telnet/config_flow.py index bb503229ebb..d714057e6f7 100644 --- a/homeassistant/components/vlc_telnet/config_flow.py +++ b/homeassistant/components/vlc_telnet/config_flow.py @@ -104,10 +104,6 @@ class VLCTelnetConfigFlow(ConfigFlow, domain=DOMAIN): step_id="user", data_schema=user_form_schema(user_input), errors=errors ) - async def async_step_import(self, user_input: dict[str, Any]) -> FlowResult: - """Handle the import step.""" - return await self.async_step_user(user_input) - async def async_step_reauth(self, data: dict[str, Any]) -> FlowResult: """Handle reauth flow.""" self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"]) diff --git a/homeassistant/components/vlc_telnet/media_player.py b/homeassistant/components/vlc_telnet/media_player.py index 0bb157ab2ae..1aa612ade25 100644 --- a/homeassistant/components/vlc_telnet/media_player.py +++ b/homeassistant/components/vlc_telnet/media_player.py @@ -7,9 +7,8 @@ from typing import Any, Callable, TypeVar, cast from aiovlc.client import Client from aiovlc.exceptions import AuthError, CommandError, ConnectError -import voluptuous as vol -from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity +from homeassistant.components.media_player import MediaPlayerEntity from homeassistant.components.media_player.const import ( MEDIA_TYPE_MUSIC, SUPPORT_CLEAR_PLAYLIST, @@ -24,25 +23,15 @@ from homeassistant.components.media_player.const import ( SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, ) -from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry -from homeassistant.const import ( - CONF_HOST, - CONF_NAME, - CONF_PASSWORD, - CONF_PORT, - STATE_IDLE, - STATE_PAUSED, - STATE_PLAYING, -) +from homeassistant.config_entries import ConfigEntry +from homeassistant.const import CONF_NAME, STATE_IDLE, STATE_PAUSED, STATE_PLAYING from homeassistant.core import HomeAssistant -import homeassistant.helpers.config_validation as cv from homeassistant.helpers.device_registry import DeviceEntryType from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType import homeassistant.util.dt as dt_util -from .const import DATA_AVAILABLE, DATA_VLC, DEFAULT_NAME, DEFAULT_PORT, DOMAIN, LOGGER +from .const import DATA_AVAILABLE, DATA_VLC, DEFAULT_NAME, DOMAIN, LOGGER MAX_VOLUME = 500 @@ -59,36 +48,10 @@ SUPPORT_VLC = ( | SUPPORT_VOLUME_MUTE | SUPPORT_VOLUME_SET ) -PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( - { - vol.Required(CONF_HOST): cv.string, - vol.Required(CONF_PASSWORD): cv.string, - vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.positive_int, - vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, - } -) Func = TypeVar("Func", bound=Callable[..., Any]) -async def async_setup_platform( - hass: HomeAssistant, - config: ConfigType, - async_add_entities: AddEntitiesCallback, - discovery_info: DiscoveryInfoType | None = None, -) -> None: - """Set up the vlc platform.""" - LOGGER.warning( - "Loading VLC media player Telnet integration via platform setup is deprecated; " - "Please remove it from your configuration" - ) - hass.async_create_task( - hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=config - ) - ) - - async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: diff --git a/tests/components/vlc_telnet/test_config_flow.py b/tests/components/vlc_telnet/test_config_flow.py index 6a0659b6360..f86644b3447 100644 --- a/tests/components/vlc_telnet/test_config_flow.py +++ b/tests/components/vlc_telnet/test_config_flow.py @@ -79,38 +79,7 @@ async def test_user_flow( assert len(mock_setup_entry.mock_calls) == 1 -async def test_import_flow(hass: HomeAssistant) -> None: - """Test successful import flow.""" - test_data = { - "password": "test-password", - "host": "1.1.1.1", - "port": 8888, - "name": "custom name", - } - with patch("homeassistant.components.vlc_telnet.config_flow.Client.connect"), patch( - "homeassistant.components.vlc_telnet.config_flow.Client.login" - ), patch( - "homeassistant.components.vlc_telnet.config_flow.Client.disconnect" - ), patch( - "homeassistant.components.vlc_telnet.async_setup_entry", - return_value=True, - ) as mock_setup_entry: - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_IMPORT}, - data=test_data, - ) - await hass.async_block_till_done() - - assert result["type"] == RESULT_TYPE_CREATE_ENTRY - assert result["title"] == test_data["name"] - assert result["data"] == test_data - assert len(mock_setup_entry.mock_calls) == 1 - - -@pytest.mark.parametrize( - "source", [config_entries.SOURCE_USER, config_entries.SOURCE_IMPORT] -) +@pytest.mark.parametrize("source", [config_entries.SOURCE_USER]) async def test_abort_already_configured(hass: HomeAssistant, source: str) -> None: """Test we handle already configured host.""" entry_data = { @@ -133,9 +102,7 @@ async def test_abort_already_configured(hass: HomeAssistant, source: str) -> Non assert result["reason"] == "already_configured" -@pytest.mark.parametrize( - "source", [config_entries.SOURCE_USER, config_entries.SOURCE_IMPORT] -) +@pytest.mark.parametrize("source", [config_entries.SOURCE_USER]) @pytest.mark.parametrize( "error, connect_side_effect, login_side_effect", [