mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Improve logic for detecting unused ignore translations (#128441)
This commit is contained in:
parent
42e6ac4f6d
commit
120e17fa1e
@ -475,14 +475,14 @@ async def _ensure_translation_exists(
|
||||
) -> None:
|
||||
"""Raise if translation doesn't exist."""
|
||||
full_key = f"component.{component}.{category}.{key}"
|
||||
if full_key in ignore_translations:
|
||||
ignore_translations[full_key] = "used"
|
||||
return
|
||||
|
||||
translations = await async_get_translations(hass, "en", category, [component])
|
||||
if full_key in translations:
|
||||
return
|
||||
|
||||
if full_key in ignore_translations:
|
||||
ignore_translations[full_key] = "used"
|
||||
return
|
||||
|
||||
key_parts = key.split(".")
|
||||
# Ignore step data translations if title or description exists
|
||||
if (
|
||||
|
@ -84,7 +84,7 @@
|
||||
'type': <FlowResultType.ABORT: 'abort'>,
|
||||
})
|
||||
# ---
|
||||
# name: test_failed_connect[component.gardena_bluetooth.config.abort.cannot_connect]
|
||||
# name: test_failed_connect
|
||||
FlowResultSnapshot({
|
||||
'data_schema': list([
|
||||
dict({
|
||||
@ -109,7 +109,7 @@
|
||||
'type': <FlowResultType.FORM: 'form'>,
|
||||
})
|
||||
# ---
|
||||
# name: test_failed_connect[component.gardena_bluetooth.config.abort.cannot_connect].1
|
||||
# name: test_failed_connect.1
|
||||
FlowResultSnapshot({
|
||||
'data_schema': None,
|
||||
'description_placeholders': dict({
|
||||
@ -124,7 +124,7 @@
|
||||
'type': <FlowResultType.FORM: 'form'>,
|
||||
})
|
||||
# ---
|
||||
# name: test_failed_connect[component.gardena_bluetooth.config.abort.cannot_connect].2
|
||||
# name: test_failed_connect.2
|
||||
FlowResultSnapshot({
|
||||
'description_placeholders': dict({
|
||||
'error': 'something went wrong',
|
||||
|
@ -50,10 +50,6 @@ async def test_user_selection(
|
||||
assert result == snapshot
|
||||
|
||||
|
||||
@pytest.mark.parametrize( # Remove when translations fixed
|
||||
"ignore_translations",
|
||||
["component.gardena_bluetooth.config.abort.cannot_connect"],
|
||||
)
|
||||
async def test_failed_connect(
|
||||
hass: HomeAssistant,
|
||||
mock_client: Mock,
|
||||
|
@ -437,10 +437,6 @@ async def test_multiple_config_entries(
|
||||
assert len(entries) == 2
|
||||
|
||||
|
||||
@pytest.mark.parametrize( # Remove when translations fixed
|
||||
"ignore_translations",
|
||||
["component.google.config.abort.missing_credentials"],
|
||||
)
|
||||
async def test_missing_configuration(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
|
@ -45,10 +45,6 @@ def current_request_with_host(current_request: MagicMock) -> None:
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize( # Remove when translations fixed
|
||||
"ignore_translations",
|
||||
["component.iotty.config.abort.missing_credentials"],
|
||||
)
|
||||
async def test_config_flow_no_credentials(hass: HomeAssistant) -> None:
|
||||
"""Test config flow base case with no credentials registered."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -101,10 +101,6 @@ async def test_discovery(hass: HomeAssistant) -> None:
|
||||
assert result2["reason"] == "no_devices_found"
|
||||
|
||||
|
||||
@pytest.mark.parametrize( # Remove when translations fixed
|
||||
"ignore_translations",
|
||||
["component.lifx.config.abort.cannot_connect"],
|
||||
)
|
||||
async def test_discovery_but_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test we can discover the device but we cannot connect."""
|
||||
with _patch_discovery(), _patch_config_flow_try_connect(no_device=True):
|
||||
|
@ -73,10 +73,6 @@ async def test_form(hass: HomeAssistant, mock_login, mock_get_devices) -> None:
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.parametrize( # Remove when translations fixed
|
||||
"ignore_translations",
|
||||
["component.melcloud.config.abort.cannot_connect"],
|
||||
)
|
||||
@pytest.mark.parametrize(
|
||||
("error", "reason"),
|
||||
[(ClientError(), "cannot_connect"), (TimeoutError(), "cannot_connect")],
|
||||
|
@ -89,10 +89,6 @@ async def test_form_errors(
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@pytest.mark.parametrize( # Remove when translations fixed
|
||||
"ignore_translations",
|
||||
["component.teslemetry.config.abort.reauth_successful"],
|
||||
)
|
||||
async def test_reauth(hass: HomeAssistant, mock_metadata: AsyncMock) -> None:
|
||||
"""Test reauth flow."""
|
||||
|
||||
@ -124,10 +120,6 @@ async def test_reauth(hass: HomeAssistant, mock_metadata: AsyncMock) -> None:
|
||||
assert mock_entry.data == CONFIG
|
||||
|
||||
|
||||
@pytest.mark.parametrize( # Remove when translations fixed
|
||||
"ignore_translations",
|
||||
["component.teslemetry.config.abort.reauth_successful"],
|
||||
)
|
||||
@pytest.mark.parametrize(
|
||||
("side_effect", "error"),
|
||||
[
|
||||
|
@ -22,10 +22,6 @@ CLIENT_SECRET = "6789"
|
||||
DOMAIN = "yolink"
|
||||
|
||||
|
||||
@pytest.mark.parametrize( # Remove when translations fixed
|
||||
"ignore_translations",
|
||||
["component.yolink.config.abort.missing_credentials"],
|
||||
)
|
||||
async def test_abort_if_no_configuration(hass: HomeAssistant) -> None:
|
||||
"""Check flow abort when no configuration."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
Loading…
x
Reference in New Issue
Block a user