From cdeb91ea127d4777e9472f5c5f6873fc79cd7546 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Thu, 22 Dec 2022 16:42:37 +0100 Subject: [PATCH] Fix title of Matter integration (#84385) * Set title for Matter integration to integration name * Update homeassistant/components/matter/config_flow.py Co-authored-by: Franck Nijhof * Update title in tests * one more title fix Co-authored-by: Franck Nijhof --- .../components/matter/config_flow.py | 5 +-- tests/components/matter/test_config_flow.py | 34 +++++++++---------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/homeassistant/components/matter/config_flow.py b/homeassistant/components/matter/config_flow.py index f570b0cf14c..98146a6ae01 100644 --- a/homeassistant/components/matter/config_flow.py +++ b/homeassistant/components/matter/config_flow.py @@ -34,6 +34,7 @@ from .const import ( ADDON_SETUP_TIMEOUT = 5 ADDON_SETUP_TIMEOUT_ROUNDS = 40 DEFAULT_URL = "ws://localhost:5580/ws" +DEFAULT_TITLE = "Matter" ON_SUPERVISOR_SCHEMA = vol.Schema({vol.Optional(CONF_USE_ADDON, default=True): bool}) @@ -306,7 +307,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): CONF_USE_ADDON: self.use_addon, CONF_INTEGRATION_CREATED_ADDON: self.integration_created_addon, }, - title=self.ws_address, + title=DEFAULT_TITLE, ) await self.hass.config_entries.async_reload(config_entry.entry_id) raise AbortFlow("reconfiguration_successful") @@ -316,7 +317,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): self.hass.config_entries.flow.async_abort(progress["flow_id"]) return self.async_create_entry( - title=self.ws_address, + title=DEFAULT_TITLE, data={ CONF_URL: self.ws_address, CONF_USE_ADDON: self.use_addon, diff --git a/tests/components/matter/test_config_flow.py b/tests/components/matter/test_config_flow.py index cad8cd91eb0..1a31998484b 100644 --- a/tests/components/matter/test_config_flow.py +++ b/tests/components/matter/test_config_flow.py @@ -99,7 +99,7 @@ async def test_manual_create_entry( assert client_connect.call_count == 1 assert result["type"] == FlowResultType.CREATE_ENTRY - assert result["title"] == "ws://localhost:5580/ws" + assert result["title"] == "Matter" assert result["data"] == { "url": "ws://localhost:5580/ws", "integration_created_addon": False, @@ -172,7 +172,7 @@ async def test_manual_already_configured( assert entry.data["url"] == "ws://localhost:5580/ws" assert entry.data["use_addon"] is False assert entry.data["integration_created_addon"] is False - assert entry.title == "ws://localhost:5580/ws" + assert entry.title == "Matter" assert setup_entry.call_count == 1 @@ -202,7 +202,7 @@ async def test_supervisor_discovery( assert addon_info.call_count == 1 assert client_connect.call_count == 0 assert result["type"] == FlowResultType.CREATE_ENTRY - assert result["title"] == "ws://host1:5581/ws" + assert result["title"] == "Matter" assert result["data"] == { "url": "ws://host1:5581/ws", "use_addon": True, @@ -294,7 +294,7 @@ async def test_clean_supervisor_discovery_on_user_create( assert len(hass.config_entries.flow.async_progress()) == 0 assert client_connect.call_count == 1 assert result["type"] == FlowResultType.CREATE_ENTRY - assert result["title"] == "ws://localhost:5580/ws" + assert result["title"] == "Matter" assert result["data"] == { "url": "ws://localhost:5580/ws", "use_addon": False, @@ -313,7 +313,7 @@ async def test_abort_supervisor_discovery_with_existing_entry( entry = MockConfigEntry( domain=DOMAIN, data={"url": "ws://localhost:5580/ws"}, - title="ws://localhost:5580/ws", + title="Matter", ) entry.add_to_hass(hass) @@ -424,7 +424,7 @@ async def test_supervisor_discovery_addon_not_running( assert start_addon.call_args == call(hass, "core_matter_server") assert client_connect.call_count == 1 assert result["type"] == FlowResultType.CREATE_ENTRY - assert result["title"] == "ws://host1:5581/ws" + assert result["title"] == "Matter" assert result["data"] == { "url": "ws://host1:5581/ws", "use_addon": True, @@ -481,7 +481,7 @@ async def test_supervisor_discovery_addon_not_installed( assert start_addon.call_args == call(hass, "core_matter_server") assert client_connect.call_count == 1 assert result["type"] == FlowResultType.CREATE_ENTRY - assert result["title"] == "ws://host1:5581/ws" + assert result["title"] == "Matter" assert result["data"] == { "url": "ws://host1:5581/ws", "use_addon": True, @@ -521,7 +521,7 @@ async def test_not_addon( assert client_connect.call_count == 1 assert result["type"] == FlowResultType.CREATE_ENTRY - assert result["title"] == "ws://localhost:5581/ws" + assert result["title"] == "Matter" assert result["data"] == { "url": "ws://localhost:5581/ws", "use_addon": False, @@ -555,7 +555,7 @@ async def test_addon_running( assert addon_info.call_count == 1 assert client_connect.call_count == 1 assert result["type"] == FlowResultType.CREATE_ENTRY - assert result["title"] == "ws://host1:5581/ws" + assert result["title"] == "Matter" assert result["data"] == { "url": "ws://host1:5581/ws", "use_addon": True, @@ -656,7 +656,7 @@ async def test_addon_running_already_configured( data={ "url": "ws://localhost:5580/ws", }, - title="ws://localhost:5580/ws", + title="Matter", ) entry.add_to_hass(hass) @@ -676,7 +676,7 @@ async def test_addon_running_already_configured( assert result["type"] == FlowResultType.ABORT assert result["reason"] == "reconfiguration_successful" assert entry.data["url"] == "ws://host1:5581/ws" - assert entry.title == "ws://host1:5581/ws" + assert entry.title == "Matter" assert setup_entry.call_count == 1 @@ -711,7 +711,7 @@ async def test_addon_installed( assert start_addon.call_args == call(hass, "core_matter_server") assert result["type"] == FlowResultType.CREATE_ENTRY - assert result["title"] == "ws://host1:5581/ws" + assert result["title"] == "Matter" assert result["data"] == { "url": "ws://host1:5581/ws", "use_addon": True, @@ -804,7 +804,7 @@ async def test_addon_installed_already_configured( data={ "url": "ws://localhost:5580/ws", }, - title="ws://localhost:5580/ws", + title="Matter", ) entry.add_to_hass(hass) @@ -831,7 +831,7 @@ async def test_addon_installed_already_configured( assert result["type"] == FlowResultType.ABORT assert result["reason"] == "reconfiguration_successful" assert entry.data["url"] == "ws://host1:5581/ws" - assert entry.title == "ws://host1:5581/ws" + assert entry.title == "Matter" assert setup_entry.call_count == 1 @@ -877,7 +877,7 @@ async def test_addon_not_installed( assert start_addon.call_args == call(hass, "core_matter_server") assert result["type"] == FlowResultType.CREATE_ENTRY - assert result["title"] == "ws://host1:5581/ws" + assert result["title"] == "Matter" assert result["data"] == { "url": "ws://host1:5581/ws", "use_addon": True, @@ -938,7 +938,7 @@ async def test_addon_not_installed_already_configured( data={ "url": "ws://localhost:5580/ws", }, - title="ws://localhost:5580/ws", + title="Matter", ) entry.add_to_hass(hass) @@ -975,5 +975,5 @@ async def test_addon_not_installed_already_configured( assert result["type"] == FlowResultType.ABORT assert result["reason"] == "reconfiguration_successful" assert entry.data["url"] == "ws://host1:5581/ws" - assert entry.title == "ws://host1:5581/ws" + assert entry.title == "Matter" assert setup_entry.call_count == 1