Remove deprecated yaml config from vlc_telnet (#62542)

pull/62547/head
Robert Hillis 2021-12-21 17:37:46 -05:00 committed by GitHub
parent 550fe18603
commit 1279592a98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 80 deletions

View File

@ -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"])

View File

@ -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:

View File

@ -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",
[