mirror of
https://github.com/home-assistant/core.git
synced 2026-10-06 06:15:47 -04:00
Handle error while getting wan status in FRITZ!Box Tools (#184133)
This commit is contained in:
@@ -269,7 +269,11 @@ class FritzBoxTools(DataUpdateCoordinator[UpdateCoordinatorDataType]):
|
||||
|
||||
if self.fritz_status.has_wan_support:
|
||||
self.device_conn_type = self.fritz_status.connection_service
|
||||
self.device_is_router = self.fritz_status.has_wan_enabled
|
||||
try:
|
||||
self.device_is_router = self.fritz_status.has_wan_enabled
|
||||
except FritzActionError:
|
||||
LOGGER.debug("assume that device has no wan enabled", exc_info=True)
|
||||
self.device_is_router = False
|
||||
|
||||
self.has_call_deflections = "X_AVM-DE_OnTel1" in self.connection.services
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ from fritzconnection.core.exceptions import (
|
||||
FritzConnectionException,
|
||||
FritzSecurityError,
|
||||
)
|
||||
from fritzconnection.lib.fritzstatus import FritzStatus
|
||||
from fritzconnection.lib.fritztools import ArgumentNamespace
|
||||
import pytest
|
||||
|
||||
@@ -257,6 +258,43 @@ async def test_async_get_wan_access_success(
|
||||
assert await fritz_tools._async_get_wan_access("192.168.1.2") is True
|
||||
|
||||
|
||||
async def test_setup_ignores_wan_enabled_action_error(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
patch_fritzconnectioncached_globally: FritzConnectionMock,
|
||||
) -> None:
|
||||
"""Test WAN capability check falls back when the router reports a call error."""
|
||||
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
coordinator = FritzBoxTools(
|
||||
hass=hass,
|
||||
config_entry=mock_config_entry,
|
||||
password=mock_config_entry.data["password"],
|
||||
port=mock_config_entry.data["port"],
|
||||
)
|
||||
hass.data.setdefault(FRITZ_DATA_KEY, FritzData())
|
||||
|
||||
with (
|
||||
patch.object(
|
||||
FritzStatus,
|
||||
"has_wan_enabled",
|
||||
new_callable=PropertyMock,
|
||||
side_effect=FritzActionError("401 Invalid Action."),
|
||||
),
|
||||
patch.object(
|
||||
FritzStatus,
|
||||
"has_wan_support",
|
||||
new_callable=PropertyMock,
|
||||
return_value=True,
|
||||
),
|
||||
):
|
||||
await coordinator.async_setup()
|
||||
|
||||
assert coordinator.device_is_router is False
|
||||
assert "assume that device has no wan enabled" in caplog.text
|
||||
|
||||
|
||||
async def test_async_update_hosts_info_attributes_branches(
|
||||
fritz_tools,
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user