mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Improve check for user-visible flows when checking translations in tests (#128434)
* Improve check for user-visible flows when checking translations in tests * Fix nest (from DHCP) * Ignore homeassistant_hardware * Improve logic
This commit is contained in:
parent
260d919f80
commit
2542ddd30a
@ -45,6 +45,7 @@
|
||||
"abort": {
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_account%]",
|
||||
"missing_configuration": "[%key:common::config_flow::abort::oauth2_missing_configuration%]",
|
||||
"missing_credentials": "[%key:common::config_flow::abort::oauth2_missing_credentials%]",
|
||||
"authorize_url_timeout": "[%key:common::config_flow::abort::oauth2_authorize_url_timeout%]",
|
||||
"unknown_authorize_url_generation": "[%key:common::config_flow::abort::unknown_authorize_url_generation%]",
|
||||
"no_url_available": "[%key:common::config_flow::abort::oauth2_no_url_available%]",
|
||||
|
@ -533,11 +533,17 @@ def check_config_translations(ignore_translations: str | list[str]) -> Generator
|
||||
else:
|
||||
return result
|
||||
|
||||
if (
|
||||
result["type"] is FlowResultType.ABORT
|
||||
and flow.source != SOURCE_SYSTEM
|
||||
and flow.source not in DISCOVERY_SOURCES
|
||||
):
|
||||
# Check if this flow has been seen before
|
||||
# Gets set to False on first run, and to True on subsequent runs
|
||||
setattr(flow, "__flow_seen_before", hasattr(flow, "__flow_seen_before"))
|
||||
|
||||
if result["type"] is FlowResultType.ABORT:
|
||||
# We don't need translations for a discovery flow which immediately
|
||||
# aborts, since such flows won't be seen by users
|
||||
if not flow.__flow_seen_before and (
|
||||
flow.source == SOURCE_SYSTEM or flow.source in DISCOVERY_SOURCES
|
||||
):
|
||||
return result
|
||||
await _ensure_translation_exists(
|
||||
flow.hass,
|
||||
_ignore_translations,
|
||||
|
@ -30,6 +30,10 @@ async def fixture_mock_supervisor_client(supervisor_client: AsyncMock):
|
||||
"""Mock supervisor client in tests."""
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ignore_translations",
|
||||
["component.test_firmware_domain.config.abort.unsupported_firmware"],
|
||||
)
|
||||
@pytest.mark.parametrize(
|
||||
"next_step",
|
||||
[
|
||||
@ -60,6 +64,10 @@ async def test_config_flow_cannot_probe_firmware(
|
||||
assert result["reason"] == "unsupported_firmware"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ignore_translations",
|
||||
["component.test_firmware_domain.config.abort.not_hassio"],
|
||||
)
|
||||
async def test_config_flow_zigbee_not_hassio_wrong_firmware(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
@ -85,6 +93,10 @@ async def test_config_flow_zigbee_not_hassio_wrong_firmware(
|
||||
assert result["reason"] == "not_hassio"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ignore_translations",
|
||||
["component.test_firmware_domain.config.abort.addon_already_running"],
|
||||
)
|
||||
async def test_config_flow_zigbee_flasher_addon_already_running(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
@ -119,6 +131,10 @@ async def test_config_flow_zigbee_flasher_addon_already_running(
|
||||
assert result["reason"] == "addon_already_running"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ignore_translations",
|
||||
["component.test_firmware_domain.config.abort.addon_info_failed"],
|
||||
)
|
||||
async def test_config_flow_zigbee_flasher_addon_info_fails(hass: HomeAssistant) -> None:
|
||||
"""Test failure case when flasher addon cannot be installed."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@ -152,6 +168,10 @@ async def test_config_flow_zigbee_flasher_addon_info_fails(hass: HomeAssistant)
|
||||
assert result["reason"] == "addon_info_failed"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ignore_translations",
|
||||
["component.test_firmware_domain.config.abort.addon_install_failed"],
|
||||
)
|
||||
async def test_config_flow_zigbee_flasher_addon_install_fails(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
@ -182,6 +202,10 @@ async def test_config_flow_zigbee_flasher_addon_install_fails(
|
||||
assert result["reason"] == "addon_install_failed"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ignore_translations",
|
||||
["component.test_firmware_domain.config.abort.addon_set_config_failed"],
|
||||
)
|
||||
async def test_config_flow_zigbee_flasher_addon_set_config_fails(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
@ -216,6 +240,10 @@ async def test_config_flow_zigbee_flasher_addon_set_config_fails(
|
||||
assert result["reason"] == "addon_set_config_failed"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ignore_translations",
|
||||
["component.test_firmware_domain.config.abort.addon_start_failed"],
|
||||
)
|
||||
async def test_config_flow_zigbee_flasher_run_fails(hass: HomeAssistant) -> None:
|
||||
"""Test failure case when flasher addon fails to run."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@ -277,6 +305,10 @@ async def test_config_flow_zigbee_flasher_uninstall_fails(hass: HomeAssistant) -
|
||||
assert result["step_id"] == "confirm_zigbee"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ignore_translations",
|
||||
["component.test_firmware_domain.config.abort.not_hassio_thread"],
|
||||
)
|
||||
async def test_config_flow_thread_not_hassio(hass: HomeAssistant) -> None:
|
||||
"""Test when the stick is used with a non-hassio setup and Thread is selected."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@ -300,6 +332,10 @@ async def test_config_flow_thread_not_hassio(hass: HomeAssistant) -> None:
|
||||
assert result["reason"] == "not_hassio_thread"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ignore_translations",
|
||||
["component.test_firmware_domain.config.abort.addon_info_failed"],
|
||||
)
|
||||
async def test_config_flow_thread_addon_info_fails(hass: HomeAssistant) -> None:
|
||||
"""Test failure case when flasher addon cannot be installed."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@ -324,6 +360,10 @@ async def test_config_flow_thread_addon_info_fails(hass: HomeAssistant) -> None:
|
||||
assert result["reason"] == "addon_info_failed"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ignore_translations",
|
||||
["component.test_firmware_domain.config.abort.otbr_addon_already_running"],
|
||||
)
|
||||
async def test_config_flow_thread_addon_already_running(hass: HomeAssistant) -> None:
|
||||
"""Test failure case when the Thread addon is already running."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@ -359,6 +399,10 @@ async def test_config_flow_thread_addon_already_running(hass: HomeAssistant) ->
|
||||
assert result["reason"] == "otbr_addon_already_running"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ignore_translations",
|
||||
["component.test_firmware_domain.config.abort.addon_install_failed"],
|
||||
)
|
||||
async def test_config_flow_thread_addon_install_fails(hass: HomeAssistant) -> None:
|
||||
"""Test failure case when flasher addon cannot be installed."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@ -386,6 +430,10 @@ async def test_config_flow_thread_addon_install_fails(hass: HomeAssistant) -> No
|
||||
assert result["reason"] == "addon_install_failed"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ignore_translations",
|
||||
["component.test_firmware_domain.config.abort.addon_set_config_failed"],
|
||||
)
|
||||
async def test_config_flow_thread_addon_set_config_fails(hass: HomeAssistant) -> None:
|
||||
"""Test failure case when flasher addon cannot be configured."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@ -413,6 +461,10 @@ async def test_config_flow_thread_addon_set_config_fails(hass: HomeAssistant) ->
|
||||
assert result["reason"] == "addon_set_config_failed"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ignore_translations",
|
||||
["component.test_firmware_domain.config.abort.addon_start_failed"],
|
||||
)
|
||||
async def test_config_flow_thread_flasher_run_fails(hass: HomeAssistant) -> None:
|
||||
"""Test failure case when flasher addon fails to run."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
Loading…
x
Reference in New Issue
Block a user