Skip to content

Commit

Permalink
Restore original websocket commands for config entries (#93707)
Browse files Browse the repository at this point in the history
Restore original websocket commands and add "config_entries/get_single"
  • Loading branch information
marvin-w committed May 29, 2023
1 parent 5f584d5 commit 795ef07
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
12 changes: 6 additions & 6 deletions homeassistant/components/config/config_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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],
Expand Down
6 changes: 3 additions & 3 deletions tests/components/bluetooth/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
)
Expand Down Expand Up @@ -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",
}
)
Expand Down Expand Up @@ -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",
}
)
Expand Down
22 changes: 12 additions & 10 deletions tests/components/config/test_config_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,9 @@ async def async_step_finish(self, user_input=None):
}


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)
Expand All @@ -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,
}
)
Expand All @@ -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",
}
)
Expand Down Expand Up @@ -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"] == [
{
Expand Down Expand Up @@ -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",
}
Expand All @@ -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"],
}
)
Expand Down Expand Up @@ -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",
}
)
Expand Down Expand Up @@ -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",
}
)
Expand Down Expand Up @@ -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"],
}
)
Expand All @@ -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"],
}
)
Expand Down
6 changes: 3 additions & 3 deletions tests/components/shelly/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
)
Expand All @@ -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",
}
)
Expand All @@ -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",
}
)
Expand Down

0 comments on commit 795ef07

Please sign in to comment.