From fa2f9eac1afe1a83e50b883bcda76ab590895fe6 Mon Sep 17 00:00:00 2001 From: G Johansson Date: Tue, 16 Jan 2024 13:27:49 +0100 Subject: [PATCH] Remove config import in meteo_france (#107970) Co-authored-by: jbouwh --- .../components/meteo_france/__init__.py | 43 +------------------ .../components/meteo_france/config_flow.py | 4 -- .../meteo_france/test_config_flow.py | 29 +------------ 3 files changed, 3 insertions(+), 73 deletions(-) diff --git a/homeassistant/components/meteo_france/__init__.py b/homeassistant/components/meteo_france/__init__.py index ff29f9d2f95..3f1cd2a5e34 100644 --- a/homeassistant/components/meteo_france/__init__.py +++ b/homeassistant/components/meteo_france/__init__.py @@ -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.""" diff --git a/homeassistant/components/meteo_france/config_flow.py b/homeassistant/components/meteo_france/config_flow.py index dd62ffc24be..a3001ee25c0 100644 --- a/homeassistant/components/meteo_france/config_flow.py +++ b/homeassistant/components/meteo_france/config_flow.py @@ -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: diff --git a/tests/components/meteo_france/test_config_flow.py b/tests/components/meteo_france/test_config_flow.py index 80155d3311a..0405f8efa18 100644 --- a/tests/components/meteo_france/test_config_flow.py +++ b/tests/components/meteo_france/test_config_flow.py @@ -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,