mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Use snapshot assertion for Brother diagnostics test (#98904)
This commit is contained in:
parent
0a1ad8a119
commit
f44215d286
@ -1,66 +0,0 @@
|
|||||||
{
|
|
||||||
"black_counter": null,
|
|
||||||
"black_ink": null,
|
|
||||||
"black_ink_remaining": null,
|
|
||||||
"black_ink_status": null,
|
|
||||||
"cyan_counter": null,
|
|
||||||
"bw_counter": 709,
|
|
||||||
"belt_unit_remaining_life": 97,
|
|
||||||
"belt_unit_remaining_pages": 48436,
|
|
||||||
"black_drum_counter": 1611,
|
|
||||||
"black_drum_remaining_life": 92,
|
|
||||||
"black_drum_remaining_pages": 16389,
|
|
||||||
"black_toner": 80,
|
|
||||||
"black_toner_remaining": 75,
|
|
||||||
"black_toner_status": 1,
|
|
||||||
"color_counter": 902,
|
|
||||||
"cyan_drum_counter": 1611,
|
|
||||||
"cyan_drum_remaining_life": 92,
|
|
||||||
"cyan_drum_remaining_pages": 16389,
|
|
||||||
"cyan_ink": null,
|
|
||||||
"cyan_ink_remaining": null,
|
|
||||||
"cyan_ink_status": null,
|
|
||||||
"cyan_toner": 10,
|
|
||||||
"cyan_toner_remaining": 10,
|
|
||||||
"cyan_toner_status": 1,
|
|
||||||
"drum_counter": 986,
|
|
||||||
"drum_remaining_life": 92,
|
|
||||||
"drum_remaining_pages": 11014,
|
|
||||||
"drum_status": 1,
|
|
||||||
"duplex_unit_pages_counter": 538,
|
|
||||||
"firmware": "1.17",
|
|
||||||
"fuser_remaining_life": 97,
|
|
||||||
"fuser_unit_remaining_pages": null,
|
|
||||||
"image_counter": null,
|
|
||||||
"laser_remaining_life": null,
|
|
||||||
"laser_unit_remaining_pages": 48389,
|
|
||||||
"magenta_counter": null,
|
|
||||||
"magenta_drum_counter": 1611,
|
|
||||||
"magenta_drum_remaining_life": 92,
|
|
||||||
"magenta_drum_remaining_pages": 16389,
|
|
||||||
"magenta_ink": null,
|
|
||||||
"magenta_ink_remaining": null,
|
|
||||||
"magenta_ink_status": null,
|
|
||||||
"magenta_toner": 10,
|
|
||||||
"magenta_toner_remaining": 8,
|
|
||||||
"magenta_toner_status": 2,
|
|
||||||
"model": "HL-L2340DW",
|
|
||||||
"page_counter": 986,
|
|
||||||
"pf_kit_1_remaining_life": 98,
|
|
||||||
"pf_kit_1_remaining_pages": 48741,
|
|
||||||
"pf_kit_mp_remaining_life": null,
|
|
||||||
"pf_kit_mp_remaining_pages": null,
|
|
||||||
"serial": "0123456789",
|
|
||||||
"status": "waiting",
|
|
||||||
"uptime": "2019-09-24T12:14:56+00:00",
|
|
||||||
"yellow_counter": null,
|
|
||||||
"yellow_drum_counter": 1611,
|
|
||||||
"yellow_drum_remaining_life": 92,
|
|
||||||
"yellow_drum_remaining_pages": 16389,
|
|
||||||
"yellow_ink": null,
|
|
||||||
"yellow_ink_remaining": null,
|
|
||||||
"yellow_ink_status": null,
|
|
||||||
"yellow_toner": 10,
|
|
||||||
"yellow_toner_remaining": 2,
|
|
||||||
"yellow_toner_status": 2
|
|
||||||
}
|
|
75
tests/components/brother/snapshots/test_diagnostics.ambr
Normal file
75
tests/components/brother/snapshots/test_diagnostics.ambr
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
# serializer version: 1
|
||||||
|
# name: test_entry_diagnostics
|
||||||
|
dict({
|
||||||
|
'data': dict({
|
||||||
|
'belt_unit_remaining_life': 97,
|
||||||
|
'belt_unit_remaining_pages': 48436,
|
||||||
|
'black_counter': None,
|
||||||
|
'black_drum_counter': 1611,
|
||||||
|
'black_drum_remaining_life': 92,
|
||||||
|
'black_drum_remaining_pages': 16389,
|
||||||
|
'black_ink': None,
|
||||||
|
'black_ink_remaining': None,
|
||||||
|
'black_ink_status': None,
|
||||||
|
'black_toner': 80,
|
||||||
|
'black_toner_remaining': 75,
|
||||||
|
'black_toner_status': 1,
|
||||||
|
'bw_counter': 709,
|
||||||
|
'color_counter': 902,
|
||||||
|
'cyan_counter': None,
|
||||||
|
'cyan_drum_counter': 1611,
|
||||||
|
'cyan_drum_remaining_life': 92,
|
||||||
|
'cyan_drum_remaining_pages': 16389,
|
||||||
|
'cyan_ink': None,
|
||||||
|
'cyan_ink_remaining': None,
|
||||||
|
'cyan_ink_status': None,
|
||||||
|
'cyan_toner': 10,
|
||||||
|
'cyan_toner_remaining': 10,
|
||||||
|
'cyan_toner_status': 1,
|
||||||
|
'drum_counter': 986,
|
||||||
|
'drum_remaining_life': 92,
|
||||||
|
'drum_remaining_pages': 11014,
|
||||||
|
'drum_status': 1,
|
||||||
|
'duplex_unit_pages_counter': 538,
|
||||||
|
'firmware': '1.17',
|
||||||
|
'fuser_remaining_life': 97,
|
||||||
|
'fuser_unit_remaining_pages': None,
|
||||||
|
'image_counter': None,
|
||||||
|
'laser_remaining_life': None,
|
||||||
|
'laser_unit_remaining_pages': 48389,
|
||||||
|
'magenta_counter': None,
|
||||||
|
'magenta_drum_counter': 1611,
|
||||||
|
'magenta_drum_remaining_life': 92,
|
||||||
|
'magenta_drum_remaining_pages': 16389,
|
||||||
|
'magenta_ink': None,
|
||||||
|
'magenta_ink_remaining': None,
|
||||||
|
'magenta_ink_status': None,
|
||||||
|
'magenta_toner': 10,
|
||||||
|
'magenta_toner_remaining': 8,
|
||||||
|
'magenta_toner_status': 2,
|
||||||
|
'model': 'HL-L2340DW',
|
||||||
|
'page_counter': 986,
|
||||||
|
'pf_kit_1_remaining_life': 98,
|
||||||
|
'pf_kit_1_remaining_pages': 48741,
|
||||||
|
'pf_kit_mp_remaining_life': None,
|
||||||
|
'pf_kit_mp_remaining_pages': None,
|
||||||
|
'serial': '0123456789',
|
||||||
|
'status': 'waiting',
|
||||||
|
'uptime': '2019-09-24T12:14:56+00:00',
|
||||||
|
'yellow_counter': None,
|
||||||
|
'yellow_drum_counter': 1611,
|
||||||
|
'yellow_drum_remaining_life': 92,
|
||||||
|
'yellow_drum_remaining_pages': 16389,
|
||||||
|
'yellow_ink': None,
|
||||||
|
'yellow_ink_remaining': None,
|
||||||
|
'yellow_ink_status': None,
|
||||||
|
'yellow_toner': 10,
|
||||||
|
'yellow_toner_remaining': 2,
|
||||||
|
'yellow_toner_status': 2,
|
||||||
|
}),
|
||||||
|
'info': dict({
|
||||||
|
'host': 'localhost',
|
||||||
|
'type': 'laser',
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
# ---
|
@ -3,6 +3,8 @@ from datetime import datetime
|
|||||||
import json
|
import json
|
||||||
from unittest.mock import Mock, patch
|
from unittest.mock import Mock, patch
|
||||||
|
|
||||||
|
from syrupy import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.util.dt import UTC
|
from homeassistant.util.dt import UTC
|
||||||
|
|
||||||
@ -14,12 +16,13 @@ from tests.typing import ClientSessionGenerator
|
|||||||
|
|
||||||
|
|
||||||
async def test_entry_diagnostics(
|
async def test_entry_diagnostics(
|
||||||
hass: HomeAssistant, hass_client: ClientSessionGenerator
|
hass: HomeAssistant,
|
||||||
|
hass_client: ClientSessionGenerator,
|
||||||
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test config entry diagnostics."""
|
"""Test config entry diagnostics."""
|
||||||
entry = await init_integration(hass, skip_setup=True)
|
entry = await init_integration(hass, skip_setup=True)
|
||||||
|
|
||||||
diagnostics_data = json.loads(load_fixture("diagnostics_data.json", "brother"))
|
|
||||||
test_time = datetime(2019, 11, 11, 9, 10, 32, tzinfo=UTC)
|
test_time = datetime(2019, 11, 11, 9, 10, 32, tzinfo=UTC)
|
||||||
with patch("brother.Brother.initialize"), patch(
|
with patch("brother.Brother.initialize"), patch(
|
||||||
"brother.datetime", now=Mock(return_value=test_time)
|
"brother.datetime", now=Mock(return_value=test_time)
|
||||||
@ -32,5 +35,4 @@ async def test_entry_diagnostics(
|
|||||||
|
|
||||||
result = await get_diagnostics_for_config_entry(hass, hass_client, entry)
|
result = await get_diagnostics_for_config_entry(hass, hass_client, entry)
|
||||||
|
|
||||||
assert result["info"] == {"host": "localhost", "type": "laser"}
|
assert result == snapshot
|
||||||
assert result["data"] == diagnostics_data
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user