Skip to content

Commit c5046f7

Browse files
authored
Add check for valid abort reason translation in option flows (#128444)
1 parent f7897bb commit c5046f7

File tree

5 files changed

+69
-0
lines changed

5 files changed

+69
-0
lines changed

tests/components/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
DISCOVERY_SOURCES,
1616
ConfigEntriesFlowManager,
1717
FlowResult,
18+
OptionsFlowManager,
1819
)
1920
from homeassistant.const import STATE_OFF, STATE_ON
2021
from homeassistant.core import HomeAssistant
@@ -529,6 +530,9 @@ async def _async_handle_step(
529530
if isinstance(self, ConfigEntriesFlowManager):
530531
category = "config"
531532
component = flow.handler
533+
elif isinstance(self, OptionsFlowManager):
534+
category = "options"
535+
component = flow.hass.config_entries.async_get_entry(flow.handler).domain
532536
else:
533537
return result
534538

tests/components/homeassistant_hardware/test_config_flow_failures.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,10 @@ async def test_config_flow_thread_flasher_uninstall_fails(hass: HomeAssistant) -
526526
assert result["step_id"] == "confirm_otbr"
527527

528528

529+
@pytest.mark.parametrize(
530+
"ignore_translations",
531+
["component.test_firmware_domain.options.abort.zha_still_using_stick"],
532+
)
529533
async def test_options_flow_zigbee_to_thread_zha_configured(
530534
hass: HomeAssistant,
531535
) -> None:
@@ -563,6 +567,10 @@ async def test_options_flow_zigbee_to_thread_zha_configured(
563567
assert result["reason"] == "zha_still_using_stick"
564568

565569

570+
@pytest.mark.parametrize(
571+
"ignore_translations",
572+
["component.test_firmware_domain.options.abort.otbr_still_using_stick"],
573+
)
566574
async def test_options_flow_thread_to_zigbee_otbr_configured(
567575
hass: HomeAssistant,
568576
) -> None:

tests/components/homeassistant_hardware/test_silabs_multiprotocol_addon.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,10 @@ async def test_option_flow_install_multi_pan_addon_zha_other_radio(
453453
}
454454

455455

456+
@pytest.mark.parametrize(
457+
"ignore_translations",
458+
["component.test.options.abort.not_hassio"],
459+
)
456460
async def test_option_flow_non_hassio(
457461
hass: HomeAssistant,
458462
) -> None:
@@ -765,6 +769,10 @@ async def test_option_flow_addon_installed_same_device_do_not_uninstall_multi_pa
765769
assert result["type"] is FlowResultType.CREATE_ENTRY
766770

767771

772+
@pytest.mark.parametrize(
773+
"ignore_translations",
774+
["component.test.options.abort.addon_already_running"],
775+
)
768776
async def test_option_flow_flasher_already_running_failure(
769777
hass: HomeAssistant,
770778
addon_info,
@@ -876,6 +884,10 @@ async def test_option_flow_addon_installed_same_device_flasher_already_installed
876884
assert result["type"] is FlowResultType.CREATE_ENTRY
877885

878886

887+
@pytest.mark.parametrize(
888+
"ignore_translations",
889+
["component.test.options.abort.addon_install_failed"],
890+
)
879891
async def test_option_flow_flasher_install_failure(
880892
hass: HomeAssistant,
881893
addon_info,
@@ -942,6 +954,10 @@ async def test_option_flow_flasher_install_failure(
942954
assert result["reason"] == "addon_install_failed"
943955

944956

957+
@pytest.mark.parametrize(
958+
"ignore_translations",
959+
["component.test.options.abort.addon_start_failed"],
960+
)
945961
async def test_option_flow_flasher_addon_flash_failure(
946962
hass: HomeAssistant,
947963
addon_info,
@@ -1004,6 +1020,10 @@ async def test_option_flow_flasher_addon_flash_failure(
10041020
assert result["description_placeholders"]["addon_name"] == "Silicon Labs Flasher"
10051021

10061022

1023+
@pytest.mark.parametrize(
1024+
"ignore_translations",
1025+
["component.test.options.abort.zha_migration_failed"],
1026+
)
10071027
@patch(
10081028
"homeassistant.components.zha.radio_manager.ZhaMultiPANMigrationHelper.async_initiate_migration",
10091029
side_effect=Exception("Boom!"),
@@ -1065,6 +1085,10 @@ async def test_option_flow_uninstall_migration_initiate_failure(
10651085
mock_initiate_migration.assert_called_once()
10661086

10671087

1088+
@pytest.mark.parametrize(
1089+
"ignore_translations",
1090+
["component.test.options.abort.zha_migration_failed"],
1091+
)
10681092
@patch(
10691093
"homeassistant.components.zha.radio_manager.ZhaMultiPANMigrationHelper.async_finish_migration",
10701094
side_effect=Exception("Boom!"),
@@ -1166,6 +1190,10 @@ async def test_option_flow_do_not_install_multi_pan_addon(
11661190
assert result["type"] is FlowResultType.CREATE_ENTRY
11671191

11681192

1193+
@pytest.mark.parametrize(
1194+
"ignore_translations",
1195+
["component.test.options.abort.addon_install_failed"],
1196+
)
11691197
async def test_option_flow_install_multi_pan_addon_install_fails(
11701198
hass: HomeAssistant,
11711199
addon_store_info,
@@ -1209,6 +1237,10 @@ async def test_option_flow_install_multi_pan_addon_install_fails(
12091237
assert result["reason"] == "addon_install_failed"
12101238

12111239

1240+
@pytest.mark.parametrize(
1241+
"ignore_translations",
1242+
["component.test.options.abort.addon_start_failed"],
1243+
)
12121244
async def test_option_flow_install_multi_pan_addon_start_fails(
12131245
hass: HomeAssistant,
12141246
addon_store_info,
@@ -1271,6 +1303,10 @@ async def test_option_flow_install_multi_pan_addon_start_fails(
12711303
assert result["reason"] == "addon_start_failed"
12721304

12731305

1306+
@pytest.mark.parametrize(
1307+
"ignore_translations",
1308+
["component.test.options.abort.addon_set_config_failed"],
1309+
)
12741310
async def test_option_flow_install_multi_pan_addon_set_options_fails(
12751311
hass: HomeAssistant,
12761312
addon_store_info,
@@ -1314,6 +1350,10 @@ async def test_option_flow_install_multi_pan_addon_set_options_fails(
13141350
assert result["reason"] == "addon_set_config_failed"
13151351

13161352

1353+
@pytest.mark.parametrize(
1354+
"ignore_translations",
1355+
["component.test.options.abort.addon_info_failed"],
1356+
)
13171357
async def test_option_flow_addon_info_fails(
13181358
hass: HomeAssistant,
13191359
addon_store_info,
@@ -1337,6 +1377,10 @@ async def test_option_flow_addon_info_fails(
13371377
assert result["reason"] == "addon_info_failed"
13381378

13391379

1380+
@pytest.mark.parametrize(
1381+
"ignore_translations",
1382+
["component.test.options.abort.zha_migration_failed"],
1383+
)
13401384
@patch(
13411385
"homeassistant.components.zha.radio_manager.ZhaMultiPANMigrationHelper.async_initiate_migration",
13421386
side_effect=Exception("Boom!"),
@@ -1392,6 +1436,10 @@ async def test_option_flow_install_multi_pan_addon_zha_migration_fails_step_1(
13921436
set_addon_options.assert_not_called()
13931437

13941438

1439+
@pytest.mark.parametrize(
1440+
"ignore_translations",
1441+
["component.test.options.abort.zha_migration_failed"],
1442+
)
13951443
@patch(
13961444
"homeassistant.components.zha.radio_manager.ZhaMultiPANMigrationHelper.async_finish_migration",
13971445
side_effect=Exception("Boom!"),

tests/components/hyperion/test_config_flow.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from unittest.mock import AsyncMock, Mock, patch
1010

1111
from hyperion import const
12+
import pytest
1213

1314
from homeassistant.components import ssdp
1415
from homeassistant.components.hyperion.const import (
@@ -823,6 +824,10 @@ async def test_options_effect_show_list(hass: HomeAssistant) -> None:
823824
assert result["data"][CONF_EFFECT_HIDE_LIST] == ["effect2"]
824825

825826

827+
@pytest.mark.parametrize( # Remove when translations fixed
828+
"ignore_translations",
829+
["component.hyperion.options.abort.cannot_connect"],
830+
)
826831
async def test_options_effect_hide_list_cannot_connect(hass: HomeAssistant) -> None:
827832
"""Check an options flow effect hide list with a failed connection."""
828833

tests/components/onewire/test_config_flow.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ async def test_user_options_set_multiple(
253253
)
254254

255255

256+
@pytest.mark.parametrize( # Remove when translations fixed
257+
"ignore_translations",
258+
["component.onewire.options.abort.No configurable devices found."],
259+
)
256260
async def test_user_options_no_devices(
257261
hass: HomeAssistant, config_entry: ConfigEntry
258262
) -> None:

0 commit comments

Comments
 (0)