From fea4a00424c3e3df90c30afeed196d56f976ccbd Mon Sep 17 00:00:00 2001 From: Shay Levy <levyshay1@gmail.com> Date: Sat, 4 Jan 2025 16:31:36 +0200 Subject: [PATCH] Remove LG WebOS TV legacy uuid migration (#134671) --- .../components/webostv/config_flow.py | 23 +------------------ .../components/webostv/quality_scale.yaml | 2 +- tests/components/webostv/test_config_flow.py | 16 ------------- 3 files changed, 2 insertions(+), 39 deletions(-) diff --git a/homeassistant/components/webostv/config_flow.py b/homeassistant/components/webostv/config_flow.py index 45395bd282a..9a5eda7bbf7 100644 --- a/homeassistant/components/webostv/config_flow.py +++ b/homeassistant/components/webostv/config_flow.py @@ -3,7 +3,6 @@ from __future__ import annotations from collections.abc import Mapping -import logging from typing import Any, Self from urllib.parse import urlparse @@ -19,7 +18,6 @@ from homeassistant.config_entries import ( ) from homeassistant.const import CONF_CLIENT_SECRET, CONF_HOST, CONF_NAME from homeassistant.core import callback -from homeassistant.data_entry_flow import AbortFlow from homeassistant.helpers import config_validation as cv from . import async_control_connect, update_client_key @@ -34,8 +32,6 @@ DATA_SCHEMA = vol.Schema( extra=vol.ALLOW_EXTRA, ) -_LOGGER = logging.getLogger(__name__) - class FlowHandler(ConfigFlow, domain=DOMAIN): """WebosTV configuration flow.""" @@ -68,28 +64,11 @@ class FlowHandler(ConfigFlow, domain=DOMAIN): step_id="user", data_schema=DATA_SCHEMA, errors=errors ) - @callback - def _async_check_configured_entry(self) -> None: - """Check if entry is configured, update unique_id if needed.""" - for entry in self._async_current_entries(include_ignore=False): - if entry.data[CONF_HOST] != self._host: - continue - - if self._uuid and not entry.unique_id: - _LOGGER.debug( - "Updating unique_id for host %s, unique_id: %s", - self._host, - self._uuid, - ) - self.hass.config_entries.async_update_entry(entry, unique_id=self._uuid) - - raise AbortFlow("already_configured") - async def async_step_pairing( self, user_input: dict[str, Any] | None = None ) -> ConfigFlowResult: """Display pairing form.""" - self._async_check_configured_entry() + self._async_abort_entries_match({CONF_HOST: self._host}) self.context["title_placeholders"] = {"name": self._name} errors = {} diff --git a/homeassistant/components/webostv/quality_scale.yaml b/homeassistant/components/webostv/quality_scale.yaml index 0bd5990da4f..b6a6a5e99a4 100644 --- a/homeassistant/components/webostv/quality_scale.yaml +++ b/homeassistant/components/webostv/quality_scale.yaml @@ -11,7 +11,7 @@ rules: config-flow-test-coverage: todo config-flow: status: todo - comment: remove duplicated config flow start in tests, make sure tests ends with CREATE_ENTRY or ABORT, remove legacy uuid migration, remove name parameter, use hass.config_entries.async_setup instead of async_setup_component, snapshot in diagnostics (and other tests when possible), test_client_disconnected validate no error in log, make reauth flow more graceful + comment: remove duplicated config flow start in tests, make sure tests ends with CREATE_ENTRY or ABORT, remove name parameter, use hass.config_entries.async_setup instead of async_setup_component, snapshot in diagnostics (and other tests when possible), test_client_disconnected validate no error in log, make reauth flow more graceful dependency-transparency: done docs-actions: status: todo diff --git a/tests/components/webostv/test_config_flow.py b/tests/components/webostv/test_config_flow.py index 9b2983aab47..cc335a4fb41 100644 --- a/tests/components/webostv/test_config_flow.py +++ b/tests/components/webostv/test_config_flow.py @@ -218,22 +218,6 @@ async def test_ssdp_in_progress(hass: HomeAssistant, client) -> None: assert result2["reason"] == "already_in_progress" -async def test_ssdp_update_uuid(hass: HomeAssistant, client) -> None: - """Test that ssdp updates existing host entry uuid.""" - entry = await setup_webostv(hass, None) - assert client - assert entry.unique_id is None - - result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=MOCK_DISCOVERY_INFO - ) - await hass.async_block_till_done() - - assert result["type"] is FlowResultType.ABORT - assert result["reason"] == "already_configured" - assert entry.unique_id == MOCK_DISCOVERY_INFO.upnp[ssdp.ATTR_UPNP_UDN][5:] - - async def test_ssdp_not_update_uuid(hass: HomeAssistant, client) -> None: """Test that ssdp not updates different host.""" entry = await setup_webostv(hass, None) -- GitLab