From 795ef075da13b1594f40fa5c4e4a14873c111ff7 Mon Sep 17 00:00:00 2001 From: Marvin Wichmann Date: Mon, 29 May 2023 03:40:35 +0200 Subject: [PATCH] Restore original websocket commands for config entries (#93707) Restore original websocket commands and add "config_entries/get_single" --- .../components/config/config_entries.py | 12 +++++----- .../components/bluetooth/test_config_flow.py | 6 ++--- .../components/config/test_config_entries.py | 22 ++++++++++--------- tests/components/shelly/test_config_flow.py | 6 ++--- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/homeassistant/components/config/config_entries.py b/homeassistant/components/config/config_entries.py index 2e1ea72dfb4..d58616ff38f 100644 --- a/homeassistant/components/config/config_entries.py +++ b/homeassistant/components/config/config_entries.py @@ -41,9 +41,9 @@ async def async_setup(hass): hass.http.register_view(OptionManagerFlowIndexView(hass.config_entries.options)) hass.http.register_view(OptionManagerFlowResourceView(hass.config_entries.options)) - websocket_api.async_register_command(hass, config_entries_get_matching) + websocket_api.async_register_command(hass, config_entries_get) websocket_api.async_register_command(hass, config_entry_disable) - websocket_api.async_register_command(hass, config_entry_get) + websocket_api.async_register_command(hass, config_entry_get_single) websocket_api.async_register_command(hass, config_entry_update) websocket_api.async_register_command(hass, config_entries_subscribe) websocket_api.async_register_command(hass, config_entries_progress) @@ -288,12 +288,12 @@ def get_entry( @websocket_api.require_admin @websocket_api.websocket_command( { - "type": "config_entries/get", + "type": "config_entries/get_single", "entry_id": str, } ) @websocket_api.async_response -async def config_entry_get( +async def config_entry_get_single( hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict[str, Any], @@ -432,13 +432,13 @@ async def ignore_config_flow( @websocket_api.websocket_command( { - vol.Required("type"): "config_entries/get_matching", + vol.Required("type"): "config_entries/get", vol.Optional("type_filter"): vol.All(cv.ensure_list, [str]), vol.Optional("domain"): str, } ) @websocket_api.async_response -async def config_entries_get_matching( +async def config_entries_get( hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict[str, Any], diff --git a/tests/components/bluetooth/test_config_flow.py b/tests/components/bluetooth/test_config_flow.py index 16fe9602d39..1489f349cf4 100644 --- a/tests/components/bluetooth/test_config_flow.py +++ b/tests/components/bluetooth/test_config_flow.py @@ -36,7 +36,7 @@ async def test_options_flow_disabled_not_setup( await ws_client.send_json( { "id": 5, - "type": "config_entries/get_matching", + "type": "config_entries/get", "domain": "bluetooth", } ) @@ -370,7 +370,7 @@ async def test_options_flow_disabled_macos( await ws_client.send_json( { "id": 5, - "type": "config_entries/get_matching", + "type": "config_entries/get", "domain": "bluetooth", } ) @@ -403,7 +403,7 @@ async def test_options_flow_enabled_linux( await ws_client.send_json( { "id": 5, - "type": "config_entries/get_matching", + "type": "config_entries/get", "domain": "bluetooth", } ) diff --git a/tests/components/config/test_config_entries.py b/tests/components/config/test_config_entries.py index bbc6ce210cb..efd9617c491 100644 --- a/tests/components/config/test_config_entries.py +++ b/tests/components/config/test_config_entries.py @@ -969,7 +969,9 @@ async def test_options_flow_with_invalid_data(hass: HomeAssistant, client) -> No } -async def test_get(hass: HomeAssistant, hass_ws_client: WebSocketGenerator) -> None: +async def test_get_single( + hass: HomeAssistant, hass_ws_client: WebSocketGenerator +) -> None: """Test that we can get a config entry.""" assert await async_setup_component(hass, "config", {}) ws_client = await hass_ws_client(hass) @@ -982,7 +984,7 @@ async def test_get(hass: HomeAssistant, hass_ws_client: WebSocketGenerator) -> N await ws_client.send_json_auto_id( { - "type": "config_entries/get", + "type": "config_entries/get_single", "entry_id": entry.entry_id, } ) @@ -1006,7 +1008,7 @@ async def test_get(hass: HomeAssistant, hass_ws_client: WebSocketGenerator) -> N await ws_client.send_json_auto_id( { - "type": "config_entries/get", + "type": "config_entries/get_single", "entry_id": "blah", } ) @@ -1317,7 +1319,7 @@ async def test_get_matching_entries_ws( ws_client = await hass_ws_client(hass) - await ws_client.send_json_auto_id({"type": "config_entries/get_matching"}) + await ws_client.send_json_auto_id({"type": "config_entries/get"}) response = await ws_client.receive_json() assert response["result"] == [ { @@ -1394,7 +1396,7 @@ async def test_get_matching_entries_ws( await ws_client.send_json_auto_id( { - "type": "config_entries/get_matching", + "type": "config_entries/get", "domain": "comp1", "type_filter": "hub", } @@ -1419,7 +1421,7 @@ async def test_get_matching_entries_ws( await ws_client.send_json_auto_id( { - "type": "config_entries/get_matching", + "type": "config_entries/get", "type_filter": ["service", "device"], } ) @@ -1457,7 +1459,7 @@ async def test_get_matching_entries_ws( await ws_client.send_json_auto_id( { - "type": "config_entries/get_matching", + "type": "config_entries/get", "type_filter": "hub", } ) @@ -1500,7 +1502,7 @@ async def test_get_matching_entries_ws( ): await ws_client.send_json_auto_id( { - "type": "config_entries/get_matching", + "type": "config_entries/get", "type_filter": "hub", } ) @@ -1586,7 +1588,7 @@ async def test_get_matching_entries_ws( ): await ws_client.send_json_auto_id( { - "type": "config_entries/get_matching", + "type": "config_entries/get", "type_filter": ["helper"], } ) @@ -1602,7 +1604,7 @@ async def test_get_matching_entries_ws( ): await ws_client.send_json_auto_id( { - "type": "config_entries/get_matching", + "type": "config_entries/get", "type_filter": ["device", "hub", "service"], } ) diff --git a/tests/components/shelly/test_config_flow.py b/tests/components/shelly/test_config_flow.py index 210db65dfda..621885bef08 100644 --- a/tests/components/shelly/test_config_flow.py +++ b/tests/components/shelly/test_config_flow.py @@ -858,7 +858,7 @@ async def test_options_flow_disabled_gen_1( await ws_client.send_json( { "id": 5, - "type": "config_entries/get_matching", + "type": "config_entries/get", "domain": "shelly", } ) @@ -879,7 +879,7 @@ async def test_options_flow_enabled_gen_2( await ws_client.send_json( { "id": 5, - "type": "config_entries/get_matching", + "type": "config_entries/get", "domain": "shelly", } ) @@ -900,7 +900,7 @@ async def test_options_flow_disabled_sleepy_gen_2( await ws_client.send_json( { "id": 5, - "type": "config_entries/get_matching", + "type": "config_entries/get", "domain": "shelly", } )