Improve diagnostics tests in SFR Box API (#157483)

This commit is contained in:
epenet
2025-11-28 11:58:33 +01:00
committed by GitHub
parent ab879c07ca
commit 9e1bc637e2
3 changed files with 18 additions and 30 deletions
@@ -34,10 +34,7 @@ rules:
action-exceptions: done
reauthentication-flow: done
parallel-updates: done
test-coverage:
status: todo
comment: |
- 93% on diagnostics / 92% on sensors, need to improve overall coverage
test-coverage: done
integration-owner: done
docs-installation-parameters:
status: todo
@@ -1,5 +1,5 @@
# serializer version: 1
# name: test_entry_diagnostics[adsl]
# name: test_entry_diagnostics[adsl-ftth_get_info]
dict({
'data': dict({
'dsl': dict({
@@ -17,10 +17,7 @@
'training': 'Showtime',
'uptime': 450796,
}),
'ftth': dict({
'status': 'down',
'wanfibre': 'out',
}),
'ftth': None,
'system': dict({
'alimvoltage': 12251,
'current_datetime': '202212282233',
@@ -58,24 +55,10 @@
}),
})
# ---
# name: test_entry_diagnostics[ftth]
# name: test_entry_diagnostics[ftth-dsl_get_info]
dict({
'data': dict({
'dsl': dict({
'attenuation_down': 28.5,
'attenuation_up': 20.8,
'counter': 16,
'crc': 0,
'line_status': 'No Defect',
'linemode': 'ADSL2+',
'noise_down': 5.8,
'noise_up': 6.0,
'rate_down': 5549,
'rate_up': 187,
'status': 'up',
'training': 'Showtime',
'uptime': 450796,
}),
'dsl': None,
'ftth': dict({
'status': 'down',
'wanfibre': 'out',
+13 -5
View File
@@ -25,7 +25,10 @@ def override_platforms() -> Generator[None]:
yield
@pytest.mark.parametrize("net_infra", ["adsl", "ftth"])
@pytest.mark.parametrize(
("net_infra", "patch_to_none"),
[("adsl", "ftth_get_info"), ("ftth", "dsl_get_info")],
)
async def test_entry_diagnostics(
hass: HomeAssistant,
config_entry: ConfigEntry,
@@ -33,13 +36,18 @@ async def test_entry_diagnostics(
snapshot: SnapshotAssertion,
system_get_info: SystemInfo,
net_infra: str,
patch_to_none: str,
) -> None:
"""Test config entry diagnostics."""
system_get_info.net_infra = net_infra
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
assert (
await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
== snapshot
)
with patch(
f"homeassistant.components.sfr_box.coordinator.SFRBox.{patch_to_none}",
return_value=None,
):
assert (
await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
== snapshot
)