Launch Library: remove deprecated YAML import (#69008)

pull/69020/head
Paulus Schoutsen 2022-03-31 11:23:52 -07:00 committed by GitHub
parent ce5d20eb8e
commit bb322a18bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 59 deletions

View File

@ -4,7 +4,6 @@ from __future__ import annotations
from typing import Any
from homeassistant import config_entries
from homeassistant.const import CONF_NAME
from homeassistant.data_entry_flow import FlowResult
from .const import DOMAIN
@ -27,7 +26,3 @@ class LaunchLibraryFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return self.async_create_entry(title="Launch Library", data=user_input)
return self.async_show_form(step_id="user")
async def async_step_import(self, conf: dict[str, Any]) -> FlowResult:
"""Import a configuration from config.yaml."""
return await self.async_step_user(user_input={CONF_NAME: conf[CONF_NAME]})

View File

@ -4,25 +4,20 @@ from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass
from datetime import datetime
import logging
from typing import Any
from pylaunches.objects.event import Event
from pylaunches.objects.launch import Launch
import voluptuous as vol
from homeassistant.components.sensor import (
PLATFORM_SCHEMA,
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
)
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_NAME, PERCENTAGE
from homeassistant.core import HomeAssistant, callback
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from homeassistant.helpers.update_coordinator import (
CoordinatorEntity,
DataUpdateCoordinator,
@ -34,13 +29,6 @@ from .const import DOMAIN
DEFAULT_NEXT_LAUNCH_NAME = "Next launch"
_LOGGER = logging.getLogger(__name__)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{vol.Optional(CONF_NAME, default=DEFAULT_NEXT_LAUNCH_NAME): cv.string}
)
@dataclass
class LaunchLibrarySensorEntityDescriptionMixin:
@ -137,28 +125,6 @@ SENSOR_DESCRIPTIONS: tuple[LaunchLibrarySensorEntityDescription, ...] = (
)
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Import Launch Library configuration from yaml."""
_LOGGER.warning(
"Configuration of the launch_library platform in YAML is deprecated and will be "
"removed in Home Assistant 2022.4; Your existing configuration "
"has been imported into the UI automatically and can be safely removed "
"from your configuration.yaml file"
)
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,

View File

@ -3,29 +3,11 @@ from unittest.mock import patch
from homeassistant import data_entry_flow
from homeassistant.components.launch_library.const import DOMAIN
from homeassistant.components.launch_library.sensor import DEFAULT_NEXT_LAUNCH_NAME
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
from homeassistant.const import CONF_NAME
from homeassistant.config_entries import SOURCE_USER
from tests.common import MockConfigEntry
async def test_import(hass):
"""Test entry will be imported."""
imported_config = {CONF_NAME: DEFAULT_NEXT_LAUNCH_NAME}
with patch(
"homeassistant.components.launch_library.async_setup_entry", return_value=True
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data=imported_config
)
assert result.get("type") == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result.get("result").data == imported_config
async def test_create_entry(hass):
"""Test we can finish a config flow."""