mirror of
https://github.com/home-assistant/core.git
synced 2026-09-25 07:51:46 -05:00
Repair flow description placeholders are optional (#159385)
This commit is contained in:
@@ -811,6 +811,7 @@ async def _check_config_flow_result_translations(
|
||||
return
|
||||
|
||||
key_prefix = ""
|
||||
description_placeholders = result.get("description_placeholders")
|
||||
if isinstance(manager, ConfigEntriesFlowManager):
|
||||
category = "config"
|
||||
integration = flow.handler
|
||||
@@ -823,6 +824,12 @@ async def _check_config_flow_result_translations(
|
||||
issue_id = flow.issue_id
|
||||
issue = ir.async_get(flow.hass).async_get_issue(integration, issue_id)
|
||||
key_prefix = f"{issue.translation_key}.fix_flow."
|
||||
description_placeholders = {
|
||||
# Both are used in issue translations, and description_placeholders
|
||||
# takes precedence over translation_placeholders
|
||||
**(issue.translation_placeholders or {}),
|
||||
**(description_placeholders or {}),
|
||||
}
|
||||
else:
|
||||
return
|
||||
|
||||
@@ -838,7 +845,7 @@ async def _check_config_flow_result_translations(
|
||||
category,
|
||||
integration,
|
||||
f"{key_prefix}step.{step_id}",
|
||||
result["description_placeholders"],
|
||||
description_placeholders,
|
||||
result["data_schema"],
|
||||
ignore_translations_for_mock_domains,
|
||||
)
|
||||
@@ -852,7 +859,7 @@ async def _check_config_flow_result_translations(
|
||||
category,
|
||||
integration,
|
||||
f"{key_prefix}error.{error}",
|
||||
result["description_placeholders"],
|
||||
description_placeholders,
|
||||
)
|
||||
return
|
||||
|
||||
@@ -868,7 +875,7 @@ async def _check_config_flow_result_translations(
|
||||
category,
|
||||
integration,
|
||||
f"{key_prefix}abort.{result['reason']}",
|
||||
result["description_placeholders"],
|
||||
description_placeholders,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -80,13 +80,6 @@ async def test_device_conflict_manual(
|
||||
data = await start_repair_fix_flow(client, DOMAIN, issue_id)
|
||||
|
||||
flow_id = data["flow_id"]
|
||||
assert data["description_placeholders"] == {
|
||||
"ip": "192.168.1.2",
|
||||
"mac": "11:22:33:44:55:ab",
|
||||
"model": "esp32-iso-poe",
|
||||
"name": "test",
|
||||
"stored_mac": "11:22:33:44:55:aa",
|
||||
}
|
||||
assert data["type"] == FlowResultType.MENU
|
||||
assert data["step_id"] == "init"
|
||||
|
||||
@@ -95,13 +88,6 @@ async def test_device_conflict_manual(
|
||||
)
|
||||
|
||||
flow_id = data["flow_id"]
|
||||
assert data["description_placeholders"] == {
|
||||
"ip": "192.168.1.2",
|
||||
"mac": "11:22:33:44:55:ab",
|
||||
"model": "esp32-iso-poe",
|
||||
"name": "test",
|
||||
"stored_mac": "11:22:33:44:55:aa",
|
||||
}
|
||||
assert data["type"] == FlowResultType.FORM
|
||||
assert data["step_id"] == "manual"
|
||||
|
||||
@@ -198,13 +184,6 @@ async def test_device_conflict_migration(
|
||||
data = await start_repair_fix_flow(client, DOMAIN, issue_id)
|
||||
|
||||
flow_id = data["flow_id"]
|
||||
assert data["description_placeholders"] == {
|
||||
"ip": "test.local",
|
||||
"mac": "11:22:33:44:55:ab",
|
||||
"model": "esp32-iso-poe",
|
||||
"name": "test",
|
||||
"stored_mac": "11:22:33:44:55:aa",
|
||||
}
|
||||
assert data["type"] == FlowResultType.MENU
|
||||
assert data["step_id"] == "init"
|
||||
|
||||
@@ -213,13 +192,6 @@ async def test_device_conflict_migration(
|
||||
)
|
||||
|
||||
flow_id = data["flow_id"]
|
||||
assert data["description_placeholders"] == {
|
||||
"ip": "test.local",
|
||||
"mac": "11:22:33:44:55:ab",
|
||||
"model": "esp32-iso-poe",
|
||||
"name": "test",
|
||||
"stored_mac": "11:22:33:44:55:aa",
|
||||
}
|
||||
assert data["type"] == FlowResultType.FORM
|
||||
assert data["step_id"] == "migrate"
|
||||
|
||||
|
||||
@@ -77,14 +77,13 @@ async def test_data_secure_group_key_issue_repair_flow(
|
||||
knx.receive_data_secure_issue("11/0/0", source="1.0.1")
|
||||
knx.receive_data_secure_issue("1/2/5", source="1.0.10")
|
||||
knx.receive_data_secure_issue("1/2/5", source="1.0.1")
|
||||
_placeholders = {
|
||||
"addresses": "`1/2/5` from 1.0.1, 1.0.10\n`11/0/0` from 1.0.1", # check sorting
|
||||
"interface": "0.0.0",
|
||||
}
|
||||
issue_registry = ir.async_get(hass)
|
||||
issue = issue_registry.async_get_issue(DOMAIN, REPAIR_ISSUE_DATA_SECURE_GROUP_KEY)
|
||||
assert issue is not None
|
||||
assert issue.translation_placeholders == _placeholders
|
||||
assert issue.translation_placeholders == {
|
||||
"addresses": "`1/2/5` from 1.0.1, 1.0.10\n`11/0/0` from 1.0.1", # check sorting
|
||||
"interface": "0.0.0",
|
||||
}
|
||||
|
||||
issues = await get_repairs(hass, hass_ws_client)
|
||||
assert issues
|
||||
@@ -98,7 +97,6 @@ async def test_data_secure_group_key_issue_repair_flow(
|
||||
flow_id = flow["flow_id"]
|
||||
assert flow["type"] == FlowResultType.FORM
|
||||
assert flow["step_id"] == "secure_knxkeys"
|
||||
assert flow["description_placeholders"] == _placeholders
|
||||
|
||||
# test error handling
|
||||
with patch_file_upload(
|
||||
|
||||
Reference in New Issue
Block a user