Fix exception strings in FRITZ!Box tools (#171603)

This commit is contained in:
Michael
2026-05-20 20:55:42 +02:00
committed by GitHub
parent bb4c211fb6
commit 296caa90c1
3 changed files with 19 additions and 12 deletions
+9 -3
View File
@@ -61,14 +61,20 @@ async def async_setup_entry(hass: HomeAssistant, entry: FritzConfigEntry) -> boo
except FRITZ_AUTH_EXCEPTIONS as ex:
raise ConfigEntryAuthFailed from ex
except FRITZ_EXCEPTIONS as ex:
raise ConfigEntryNotReady from ex
raise ConfigEntryNotReady(
translation_domain=DOMAIN,
translation_key="error_connecting",
translation_placeholders={"error": str(ex)},
) from ex
if (
"X_AVM-DE_UPnP1" in avm_wrapper.connection.services
and not (await avm_wrapper.async_get_upnp_configuration())["NewEnable"]
):
# pylint: disable-next=home-assistant-exception-not-translated
raise ConfigEntryAuthFailed("Missing UPnP configuration")
raise ConfigEntryNotReady(
translation_domain=DOMAIN,
translation_key="error_upnp_disabled",
)
await avm_wrapper.async_config_entry_first_refresh()
+6 -3
View File
@@ -185,12 +185,18 @@
"config_entry_not_found": {
"message": "Failed to perform action \"{service}\". Config entry for target not found"
},
"error_connecting": {
"message": "Error connecting to the FRITZ!Box: {error}"
},
"error_parse_device_info": {
"message": "Error parsing device info. Please check the system event log of your FRITZ!Box for malformed data and clear the event list."
},
"error_refresh_hosts_info": {
"message": "Error refreshing hosts info"
},
"error_upnp_disabled": {
"message": "UPnP is disabled on the FRITZ!Box. Please enable UPnP to use this integration."
},
"service_dial_failed": {
"message": "Failed to dial, check if the click to dial service of the FRITZ!Box is activated"
},
@@ -200,9 +206,6 @@
"service_parameter_unknown": {
"message": "Action or parameter unknown"
},
"unable_to_connect": {
"message": "Unable to establish a connection"
},
"update_failed": {
"message": "Error while updating the data: {error}"
}
+4 -6
View File
@@ -115,6 +115,8 @@ async def test_setup_fail(hass: HomeAssistant, error) -> None:
await hass.async_block_till_done()
assert entry.state is ConfigEntryState.SETUP_RETRY
assert entry.state.recoverable is True
assert entry.error_reason_translation_key == "error_connecting"
async def test_setup_fail_parse_error(hass: HomeAssistant, fc_class_mock) -> None:
@@ -138,7 +140,6 @@ async def test_setup_fail_parse_error(hass: HomeAssistant, fc_class_mock) -> Non
async def test_upnp_missing(
hass: HomeAssistant,
caplog: pytest.LogCaptureFixture,
fc_class_mock,
fh_class_mock,
fs_class_mock,
@@ -157,12 +158,9 @@ async def test_upnp_missing(
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
assert entry.state is ConfigEntryState.SETUP_ERROR
assert entry.state is ConfigEntryState.SETUP_RETRY
assert entry.state.recoverable is True
assert (
"Config entry 'Mock Title' for fritz integration"
" could not authenticate: Missing UPnP configuration" in caplog.text
)
assert entry.error_reason_translation_key == "error_upnp_disabled"
async def test_execute_action_while_shutdown(