2022-06-07 23:11:38 +00:00
|
|
|
"""Tests for Fritz!Tools diagnostics platform."""
|
2024-03-08 13:50:04 +00:00
|
|
|
|
2022-02-23 00:35:22 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
from homeassistant.components.diagnostics import REDACTED
|
|
|
|
from homeassistant.components.fritz.const import DOMAIN
|
2024-05-15 19:58:29 +00:00
|
|
|
from homeassistant.components.fritz.coordinator import AvmWrapper
|
2022-02-23 00:35:22 +00:00
|
|
|
from homeassistant.components.fritz.diagnostics import TO_REDACT
|
|
|
|
from homeassistant.config_entries import ConfigEntryState
|
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
|
2022-03-04 22:43:33 +00:00
|
|
|
from .const import MOCK_MESH_MASTER_MAC, MOCK_USER_DATA
|
2022-02-23 00:35:22 +00:00
|
|
|
|
|
|
|
from tests.common import MockConfigEntry
|
|
|
|
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
2023-02-02 21:29:57 +00:00
|
|
|
from tests.typing import ClientSessionGenerator
|
2022-02-23 00:35:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def test_entry_diagnostics(
|
2023-02-02 21:29:57 +00:00
|
|
|
hass: HomeAssistant,
|
|
|
|
hass_client: ClientSessionGenerator,
|
|
|
|
fc_class_mock,
|
|
|
|
fh_class_mock,
|
2023-02-13 08:53:09 +00:00
|
|
|
) -> None:
|
2022-02-23 00:35:22 +00:00
|
|
|
"""Test config entry diagnostics."""
|
|
|
|
entry = MockConfigEntry(domain=DOMAIN, data=MOCK_USER_DATA)
|
|
|
|
entry.add_to_hass(hass)
|
|
|
|
|
2024-02-15 19:52:40 +00:00
|
|
|
await hass.config_entries.async_setup(entry.entry_id)
|
2022-02-23 00:35:22 +00:00
|
|
|
await hass.async_block_till_done()
|
2024-04-05 15:16:55 +00:00
|
|
|
assert entry.state is ConfigEntryState.LOADED
|
2022-02-23 00:35:22 +00:00
|
|
|
|
|
|
|
entry_dict = entry.as_dict()
|
|
|
|
for key in TO_REDACT:
|
|
|
|
entry_dict["data"][key] = REDACTED
|
|
|
|
result = await get_diagnostics_for_config_entry(hass, hass_client, entry)
|
|
|
|
avm_wrapper: AvmWrapper = hass.data[DOMAIN][entry.entry_id]
|
|
|
|
assert result == {
|
|
|
|
"entry": entry_dict,
|
|
|
|
"device_info": {
|
|
|
|
"client_devices": [
|
|
|
|
{
|
|
|
|
"connected_to": device.connected_to,
|
|
|
|
"connection_type": device.connection_type,
|
|
|
|
"hostname": device.hostname,
|
|
|
|
"is_connected": device.is_connected,
|
|
|
|
"last_activity": device.last_activity.isoformat(),
|
|
|
|
"wan_access": device.wan_access,
|
|
|
|
}
|
|
|
|
for _, device in avm_wrapper.devices.items()
|
|
|
|
],
|
|
|
|
"connection_type": "WANPPPConnection",
|
2023-07-21 19:58:18 +00:00
|
|
|
"current_firmware": "7.29",
|
2022-02-23 00:35:22 +00:00
|
|
|
"discovered_services": [
|
|
|
|
"DeviceInfo1",
|
|
|
|
"Hosts1",
|
|
|
|
"LANEthernetInterfaceConfig1",
|
|
|
|
"Layer3Forwarding1",
|
|
|
|
"UserInterface1",
|
|
|
|
"WANCommonIFC1",
|
|
|
|
"WANCommonInterfaceConfig1",
|
|
|
|
"WANDSLInterfaceConfig1",
|
|
|
|
"WANIPConn1",
|
|
|
|
"WANPPPConnection1",
|
2024-01-07 09:51:31 +00:00
|
|
|
"WLANConfiguration1",
|
2022-02-23 00:35:22 +00:00
|
|
|
"X_AVM-DE_Homeauto1",
|
|
|
|
"X_AVM-DE_HostFilter1",
|
|
|
|
],
|
|
|
|
"is_router": True,
|
|
|
|
"last_exception": None,
|
|
|
|
"last_update success": True,
|
|
|
|
"latest_firmware": None,
|
|
|
|
"mesh_role": "master",
|
|
|
|
"model": "FRITZ!Box 7530 AX",
|
2022-03-04 22:43:33 +00:00
|
|
|
"unique_id": MOCK_MESH_MASTER_MAC.replace("6F:12", "XX:XX"),
|
2022-02-23 00:35:22 +00:00
|
|
|
"update_available": False,
|
|
|
|
"wan_link_properties": {
|
|
|
|
"NewLayer1DownstreamMaxBitRate": 318557000,
|
|
|
|
"NewLayer1UpstreamMaxBitRate": 51805000,
|
|
|
|
"NewPhysicalLinkStatus": "Up",
|
|
|
|
"NewWANAccessType": "DSL",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|