Use snapshot assertion for Cpuspeed diagnostics test (#98907)

This commit is contained in:
Joost Lekkerkerker 2023-08-24 00:57:27 +02:00 committed by GitHub
parent 34b47a2597
commit 360d2de1e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 8 deletions

View file

@ -0,0 +1,15 @@
# serializer version: 1
# name: test_diagnostics
dict({
'arch_string_raw': 'aargh',
'brand_raw': 'Intel Ryzen 7',
'hz_actual': list([
3200000001,
0,
]),
'hz_advertised': list([
3600000001,
0,
]),
})
# ---

View file

@ -1,6 +1,8 @@
"""Tests for the diagnostics data provided by the CPU Speed integration."""
from unittest.mock import patch
from syrupy import SnapshotAssertion
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry
@ -12,6 +14,7 @@ async def test_diagnostics(
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
init_integration: MockConfigEntry,
snapshot: SnapshotAssertion,
) -> None:
"""Test diagnostics."""
info = {
@ -25,11 +28,7 @@ async def test_diagnostics(
"homeassistant.components.cpuspeed.diagnostics.cpuinfo.get_cpu_info",
return_value=info,
):
assert await get_diagnostics_for_config_entry(
hass, hass_client, init_integration
) == {
"hz_actual": [3200000001, 0],
"arch_string_raw": "aargh",
"brand_raw": "Intel Ryzen 7",
"hz_advertised": [3600000001, 0],
}
assert (
await get_diagnostics_for_config_entry(hass, hass_client, init_integration)
== snapshot
)