From b46d0fb07cd2c2f0463c3e7dc30f164b16b97bff Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Tue, 16 Jan 2024 13:13:33 +0100 Subject: [PATCH] Remove YAML import support for plum_lightpad (#108114) --- .../components/plum_lightpad/__init__.py | 54 +------------------ .../components/plum_lightpad/config_flow.py | 6 --- .../plum_lightpad/test_config_flow.py | 33 +----------- tests/components/plum_lightpad/test_init.py | 25 --------- 4 files changed, 3 insertions(+), 115 deletions(-) diff --git a/homeassistant/components/plum_lightpad/__init__.py b/homeassistant/components/plum_lightpad/__init__.py index 241c14f29b9..78c7bf7ff6a 100644 --- a/homeassistant/components/plum_lightpad/__init__.py +++ b/homeassistant/components/plum_lightpad/__init__.py @@ -3,75 +3,25 @@ import logging from aiohttp import ContentTypeError from requests.exceptions import ConnectTimeout, HTTPError -import voluptuous as vol -from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry +from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONF_PASSWORD, CONF_USERNAME, EVENT_HOMEASSISTANT_STOP, Platform, ) -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 .const import DOMAIN from .utils import load_plum _LOGGER = logging.getLogger(__name__) -CONFIG_SCHEMA = vol.Schema( - vol.All( - cv.deprecated(DOMAIN), - { - DOMAIN: vol.Schema( - { - vol.Required(CONF_USERNAME): cv.string, - vol.Required(CONF_PASSWORD): cv.string, - } - ) - }, - ), - extra=vol.ALLOW_EXTRA, -) - PLATFORMS = [Platform.LIGHT] -async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: - """Plum Lightpad Platform initialization.""" - if DOMAIN not in config: - return True - - conf = config[DOMAIN] - - _LOGGER.debug("Found Plum Lightpad configuration in config, importing") - hass.async_create_task( - hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=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": "Plum Lightpad", - }, - ) - - return True - - async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Plum Lightpad from a config entry.""" _LOGGER.debug("Setting up config entry with ID = %s", entry.unique_id) diff --git a/homeassistant/components/plum_lightpad/config_flow.py b/homeassistant/components/plum_lightpad/config_flow.py index b2afb55fc5d..9f81a57d42e 100644 --- a/homeassistant/components/plum_lightpad/config_flow.py +++ b/homeassistant/components/plum_lightpad/config_flow.py @@ -58,9 +58,3 @@ class PlumLightpadConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return self.async_create_entry( title=username, data={CONF_USERNAME: username, CONF_PASSWORD: password} ) - - async def async_step_import( - self, import_config: dict[str, Any] | None - ) -> FlowResult: - """Import a config entry from configuration.yaml.""" - return await self.async_step_user(import_config) diff --git a/tests/components/plum_lightpad/test_config_flow.py b/tests/components/plum_lightpad/test_config_flow.py index e919932be28..40852094f5b 100644 --- a/tests/components/plum_lightpad/test_config_flow.py +++ b/tests/components/plum_lightpad/test_config_flow.py @@ -22,8 +22,6 @@ async def test_form(hass: HomeAssistant) -> None: with patch( "homeassistant.components.plum_lightpad.utils.Plum.loadCloudData" ), patch( - "homeassistant.components.plum_lightpad.async_setup", return_value=True - ) as mock_setup, patch( "homeassistant.components.plum_lightpad.async_setup_entry", return_value=True, ) as mock_setup_entry: @@ -39,7 +37,6 @@ async def test_form(hass: HomeAssistant) -> None: "username": "test-plum-username", "password": "test-plum-password", } - assert len(mock_setup.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1 @@ -76,7 +73,7 @@ async def test_form_one_entry_per_email_allowed(hass: HomeAssistant) -> None: with patch( "homeassistant.components.plum_lightpad.utils.Plum.loadCloudData" - ), patch("homeassistant.components.plum_lightpad.async_setup") as mock_setup, patch( + ), patch( "homeassistant.components.plum_lightpad.async_setup_entry" ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( @@ -86,32 +83,4 @@ async def test_form_one_entry_per_email_allowed(hass: HomeAssistant) -> None: assert result2["type"] == "abort" await hass.async_block_till_done() - assert len(mock_setup.mock_calls) == 0 assert len(mock_setup_entry.mock_calls) == 0 - - -async def test_import(hass: HomeAssistant) -> None: - """Test configuring the flow using configuration.yaml.""" - - with patch( - "homeassistant.components.plum_lightpad.utils.Plum.loadCloudData" - ), patch( - "homeassistant.components.plum_lightpad.async_setup", return_value=True - ) as mock_setup, patch( - "homeassistant.components.plum_lightpad.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={"username": "test-plum-username", "password": "test-plum-password"}, - ) - assert result["type"] == "create_entry" - assert result["title"] == "test-plum-username" - assert result["data"] == { - "username": "test-plum-username", - "password": "test-plum-password", - } - await hass.async_block_till_done() - assert len(mock_setup.mock_calls) == 1 - assert len(mock_setup_entry.mock_calls) == 1 diff --git a/tests/components/plum_lightpad/test_init.py b/tests/components/plum_lightpad/test_init.py index 2a3249b7514..66402abf13c 100644 --- a/tests/components/plum_lightpad/test_init.py +++ b/tests/components/plum_lightpad/test_init.py @@ -19,31 +19,6 @@ async def test_async_setup_no_domain_config(hass: HomeAssistant) -> None: assert DOMAIN not in hass.data -async def test_async_setup_imports_from_config(hass: HomeAssistant) -> None: - """Test that specifying config will setup an entry.""" - with patch( - "homeassistant.components.plum_lightpad.utils.Plum.loadCloudData" - ) as mock_loadCloudData, patch( - "homeassistant.components.plum_lightpad.async_setup_entry", - return_value=True, - ) as mock_async_setup_entry: - result = await async_setup_component( - hass, - DOMAIN, - { - DOMAIN: { - "username": "test-plum-username", - "password": "test-plum-password", - } - }, - ) - await hass.async_block_till_done() - - assert result is True - assert len(mock_loadCloudData.mock_calls) == 1 - assert len(mock_async_setup_entry.mock_calls) == 1 - - async def test_async_setup_entry_sets_up_light(hass: HomeAssistant) -> None: """Test that configuring entry sets up light domain.""" config_entry = MockConfigEntry(