Skip to content

Commit 9e1bc63

Browse files
authored
Improve diagnostics tests in SFR Box API (home-assistant#157483)
1 parent ab879c0 commit 9e1bc63

File tree

3 files changed

+18
-30
lines changed

3 files changed

+18
-30
lines changed

homeassistant/components/sfr_box/quality_scale.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ rules:
3434
action-exceptions: done
3535
reauthentication-flow: done
3636
parallel-updates: done
37-
test-coverage:
38-
status: todo
39-
comment: |
40-
- 93% on diagnostics / 92% on sensors, need to improve overall coverage
37+
test-coverage: done
4138
integration-owner: done
4239
docs-installation-parameters:
4340
status: todo

tests/components/sfr_box/snapshots/test_diagnostics.ambr

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# serializer version: 1
2-
# name: test_entry_diagnostics[adsl]
2+
# name: test_entry_diagnostics[adsl-ftth_get_info]
33
dict({
44
'data': dict({
55
'dsl': dict({
@@ -17,10 +17,7 @@
1717
'training': 'Showtime',
1818
'uptime': 450796,
1919
}),
20-
'ftth': dict({
21-
'status': 'down',
22-
'wanfibre': 'out',
23-
}),
20+
'ftth': None,
2421
'system': dict({
2522
'alimvoltage': 12251,
2623
'current_datetime': '202212282233',
@@ -58,24 +55,10 @@
5855
}),
5956
})
6057
# ---
61-
# name: test_entry_diagnostics[ftth]
58+
# name: test_entry_diagnostics[ftth-dsl_get_info]
6259
dict({
6360
'data': dict({
64-
'dsl': dict({
65-
'attenuation_down': 28.5,
66-
'attenuation_up': 20.8,
67-
'counter': 16,
68-
'crc': 0,
69-
'line_status': 'No Defect',
70-
'linemode': 'ADSL2+',
71-
'noise_down': 5.8,
72-
'noise_up': 6.0,
73-
'rate_down': 5549,
74-
'rate_up': 187,
75-
'status': 'up',
76-
'training': 'Showtime',
77-
'uptime': 450796,
78-
}),
61+
'dsl': None,
7962
'ftth': dict({
8063
'status': 'down',
8164
'wanfibre': 'out',

tests/components/sfr_box/test_diagnostics.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,29 @@ def override_platforms() -> Generator[None]:
2525
yield
2626

2727

28-
@pytest.mark.parametrize("net_infra", ["adsl", "ftth"])
28+
@pytest.mark.parametrize(
29+
("net_infra", "patch_to_none"),
30+
[("adsl", "ftth_get_info"), ("ftth", "dsl_get_info")],
31+
)
2932
async def test_entry_diagnostics(
3033
hass: HomeAssistant,
3134
config_entry: ConfigEntry,
3235
hass_client: ClientSessionGenerator,
3336
snapshot: SnapshotAssertion,
3437
system_get_info: SystemInfo,
3538
net_infra: str,
39+
patch_to_none: str,
3640
) -> None:
3741
"""Test config entry diagnostics."""
3842
system_get_info.net_infra = net_infra
3943
await hass.config_entries.async_setup(config_entry.entry_id)
4044
await hass.async_block_till_done()
4145

42-
assert (
43-
await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
44-
== snapshot
45-
)
46+
with patch(
47+
f"homeassistant.components.sfr_box.coordinator.SFRBox.{patch_to_none}",
48+
return_value=None,
49+
):
50+
assert (
51+
await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
52+
== snapshot
53+
)

0 commit comments

Comments
 (0)