Remove config import in meteo_france (#107970)

Co-authored-by: jbouwh <jan@jbsoft.nl>
pull/108262/head
G Johansson 2024-01-16 13:27:49 +01:00 committed by GitHub
parent b46d0fb07c
commit fa2f9eac1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 73 deletions

View File

@ -7,13 +7,11 @@ from meteofrance_api.helpers import is_valid_warning_department
from meteofrance_api.model import CurrentPhenomenons, Forecast, Rain
import voluptuous as vol
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
from homeassistant.helpers.typing import ConfigType
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from .const import (
@ -34,43 +32,6 @@ SCAN_INTERVAL = timedelta(minutes=15)
CITY_SCHEMA = vol.Schema({vol.Required(CONF_CITY): cv.string})
CONFIG_SCHEMA = vol.Schema(
vol.All(
cv.deprecated(DOMAIN),
{DOMAIN: vol.Schema(vol.All(cv.ensure_list, [CITY_SCHEMA]))},
),
extra=vol.ALLOW_EXTRA,
)
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up Meteo-France from legacy config file."""
if not (conf := config.get(DOMAIN)):
return True
for city_conf in conf:
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data=city_conf
)
)
async_create_issue(
hass,
HOMEASSISTANT_DOMAIN,
f"deprecated_yaml_{DOMAIN}",
breaks_in_ha_version="2024.2.0",
is_fixable=False,
issue_domain=DOMAIN,
severity=IssueSeverity.WARNING,
translation_key="deprecated_yaml",
translation_placeholders={
"domain": DOMAIN,
"integration_title": "Météo-France",
},
)
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up an Meteo-France account from a config entry."""

View File

@ -81,10 +81,6 @@ class MeteoFranceFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
data={CONF_LATITUDE: latitude, CONF_LONGITUDE: longitude},
)
async def async_step_import(self, user_input: dict[str, Any]) -> FlowResult:
"""Import a config entry."""
return await self.async_step_user(user_input)
async def async_step_cities(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:

View File

@ -6,7 +6,7 @@ import pytest
from homeassistant import data_entry_flow
from homeassistant.components.meteo_france.const import CONF_CITY, DOMAIN
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.core import HomeAssistant
@ -80,9 +80,6 @@ def mock_controller_client_single():
def mock_setup():
"""Prevent setup."""
with patch(
"homeassistant.components.meteo_france.async_setup",
return_value=True,
), patch(
"homeassistant.components.meteo_france.async_setup_entry",
return_value=True,
):
@ -155,21 +152,6 @@ async def test_user_list(hass: HomeAssistant, client_multiple) -> None:
assert result["data"][CONF_LONGITUDE] == str(CITY_3_LON)
async def test_import(hass: HomeAssistant, client_multiple) -> None:
"""Test import step."""
# import with all
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data={CONF_CITY: CITY_2_NAME},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["result"].unique_id == f"{CITY_2_LAT}, {CITY_2_LON}"
assert result["title"] == f"{CITY_2}"
assert result["data"][CONF_LATITUDE] == str(CITY_2_LAT)
assert result["data"][CONF_LONGITUDE] == str(CITY_2_LON)
async def test_search_failed(hass: HomeAssistant, client_empty) -> None:
"""Test error displayed if no result in search."""
result = await hass.config_entries.flow.async_init(
@ -190,15 +172,6 @@ async def test_abort_if_already_setup(hass: HomeAssistant, client_single) -> Non
unique_id=f"{CITY_1_LAT}, {CITY_1_LON}",
).add_to_hass(hass)
# Should fail, same CITY same postal code (import)
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data={CONF_CITY: CITY_1_POSTAL},
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["reason"] == "already_configured"
# Should fail, same CITY same postal code (flow)
result = await hass.config_entries.flow.async_init(
DOMAIN,