mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use snapshot assertion for Airly diagnostics (#98726)
This commit is contained in:
parent
17050a3286
commit
5ad97827cf
@ -14,6 +14,7 @@ async def init_integration(hass, aioclient_mock) -> MockConfigEntry:
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
title="Home",
|
||||
entry_id="3bd2acb0e4f0476d40865546d0d91921",
|
||||
unique_id="123-456",
|
||||
data={
|
||||
"api_key": "foo",
|
||||
|
@ -1,28 +0,0 @@
|
||||
{
|
||||
"PM1": 2.83,
|
||||
"PM25": 4.37,
|
||||
"PM10": 6.06,
|
||||
"CO": 162.49,
|
||||
"NO2": 16.04,
|
||||
"O3": 41.52,
|
||||
"SO2": 13.97,
|
||||
"PRESSURE": 1019.86,
|
||||
"HUMIDITY": 68.35,
|
||||
"TEMPERATURE": 14.37,
|
||||
"PM25_LIMIT": 15.0,
|
||||
"PM25_PERCENT": 29.13,
|
||||
"PM10_LIMIT": 45.0,
|
||||
"PM10_PERCENT": 14.5,
|
||||
"CO_LIMIT": 4000,
|
||||
"CO_PERCENT": 4.06,
|
||||
"NO2_LIMIT": 25,
|
||||
"NO2_PERCENT": 64.17,
|
||||
"O3_LIMIT": 100,
|
||||
"O3_PERCENT": 41.52,
|
||||
"SO2_LIMIT": 40,
|
||||
"SO2_PERCENT": 34.93,
|
||||
"CAQI": 7.29,
|
||||
"LEVEL": "very low",
|
||||
"DESCRIPTION": "Great air here today!",
|
||||
"ADVICE": "Catch your breath!"
|
||||
}
|
52
tests/components/airly/snapshots/test_diagnostics.ambr
Normal file
52
tests/components/airly/snapshots/test_diagnostics.ambr
Normal file
@ -0,0 +1,52 @@
|
||||
# serializer version: 1
|
||||
# name: test_entry_diagnostics
|
||||
dict({
|
||||
'config_entry': dict({
|
||||
'data': dict({
|
||||
'api_key': '**REDACTED**',
|
||||
'latitude': '**REDACTED**',
|
||||
'longitude': '**REDACTED**',
|
||||
'name': 'Home',
|
||||
}),
|
||||
'disabled_by': None,
|
||||
'domain': 'airly',
|
||||
'entry_id': '3bd2acb0e4f0476d40865546d0d91921',
|
||||
'options': dict({
|
||||
}),
|
||||
'pref_disable_new_entities': False,
|
||||
'pref_disable_polling': False,
|
||||
'source': 'user',
|
||||
'title': 'Home',
|
||||
'unique_id': '**REDACTED**',
|
||||
'version': 1,
|
||||
}),
|
||||
'coordinator_data': dict({
|
||||
'ADVICE': 'Catch your breath!',
|
||||
'CAQI': 7.29,
|
||||
'CO': 162.49,
|
||||
'CO_LIMIT': 4000,
|
||||
'CO_PERCENT': 4.06,
|
||||
'DESCRIPTION': 'Great air here today!',
|
||||
'HUMIDITY': 68.35,
|
||||
'LEVEL': 'very low',
|
||||
'NO2': 16.04,
|
||||
'NO2_LIMIT': 25,
|
||||
'NO2_PERCENT': 64.17,
|
||||
'O3': 41.52,
|
||||
'O3_LIMIT': 100,
|
||||
'O3_PERCENT': 41.52,
|
||||
'PM1': 2.83,
|
||||
'PM10': 6.06,
|
||||
'PM10_LIMIT': 45,
|
||||
'PM10_PERCENT': 14.5,
|
||||
'PM25': 4.37,
|
||||
'PM25_LIMIT': 15,
|
||||
'PM25_PERCENT': 29.13,
|
||||
'PRESSURE': 1019.86,
|
||||
'SO2': 13.97,
|
||||
'SO2_LIMIT': 40,
|
||||
'SO2_PERCENT': 34.93,
|
||||
'TEMPERATURE': 14.37,
|
||||
}),
|
||||
})
|
||||
# ---
|
@ -1,12 +1,11 @@
|
||||
"""Test Airly diagnostics."""
|
||||
import json
|
||||
|
||||
from homeassistant.components.diagnostics import REDACTED
|
||||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import init_integration
|
||||
|
||||
from tests.common import load_fixture
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
from tests.typing import ClientSessionGenerator
|
||||
@ -16,30 +15,11 @@ async def test_entry_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
aioclient_mock: AiohttpClientMocker,
|
||||
hass_client: ClientSessionGenerator,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test config entry diagnostics."""
|
||||
entry = await init_integration(hass, aioclient_mock)
|
||||
|
||||
coordinator_data = json.loads(load_fixture("diagnostics_data.json", "airly"))
|
||||
|
||||
result = await get_diagnostics_for_config_entry(hass, hass_client, entry)
|
||||
|
||||
assert result["config_entry"] == {
|
||||
"entry_id": entry.entry_id,
|
||||
"version": 1,
|
||||
"domain": "airly",
|
||||
"title": "Home",
|
||||
"data": {
|
||||
"latitude": REDACTED,
|
||||
"longitude": REDACTED,
|
||||
"name": "Home",
|
||||
"api_key": REDACTED,
|
||||
},
|
||||
"options": {},
|
||||
"pref_disable_new_entities": False,
|
||||
"pref_disable_polling": False,
|
||||
"source": "user",
|
||||
"unique_id": REDACTED,
|
||||
"disabled_by": None,
|
||||
}
|
||||
assert result["coordinator_data"] == coordinator_data
|
||||
assert result == snapshot
|
||||
|
Loading…
x
Reference in New Issue
Block a user