mirror of
https://github.com/home-assistant/core.git
synced 2025-07-07 13:27:09 +00:00
Use snapshot assertion for Airnow diagnostics (#98727)
This commit is contained in:
parent
4a7088a996
commit
4518dad83b
@ -16,6 +16,7 @@ def config_entry_fixture(hass, config):
|
||||
"""Define a config entry fixture."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
entry_id="3bd2acb0e4f0476d40865546d0d91921",
|
||||
unique_id=f"{config[CONF_LATITUDE]}-{config[CONF_LONGITUDE]}",
|
||||
data=config,
|
||||
)
|
||||
|
39
tests/components/airnow/snapshots/test_diagnostics.ambr
Normal file
39
tests/components/airnow/snapshots/test_diagnostics.ambr
Normal file
@ -0,0 +1,39 @@
|
||||
# serializer version: 1
|
||||
# name: test_entry_diagnostics
|
||||
dict({
|
||||
'data': dict({
|
||||
'AQI': 44,
|
||||
'Category.Name': 'Good',
|
||||
'Category.Number': 1,
|
||||
'DateObserved': '2020-12-20',
|
||||
'HourObserved': 15,
|
||||
'Latitude': '**REDACTED**',
|
||||
'Longitude': '**REDACTED**',
|
||||
'O3': 0.048,
|
||||
'PM10': 12,
|
||||
'PM2.5': 8.9,
|
||||
'Pollutant': 'O3',
|
||||
'ReportingArea': '**REDACTED**',
|
||||
'StateCode': '**REDACTED**',
|
||||
}),
|
||||
'entry': dict({
|
||||
'data': dict({
|
||||
'api_key': '**REDACTED**',
|
||||
'latitude': '**REDACTED**',
|
||||
'longitude': '**REDACTED**',
|
||||
'radius': 75,
|
||||
}),
|
||||
'disabled_by': None,
|
||||
'domain': 'airnow',
|
||||
'entry_id': '3bd2acb0e4f0476d40865546d0d91921',
|
||||
'options': dict({
|
||||
}),
|
||||
'pref_disable_new_entities': False,
|
||||
'pref_disable_polling': False,
|
||||
'source': 'user',
|
||||
'title': '**REDACTED**',
|
||||
'unique_id': '**REDACTED**',
|
||||
'version': 1,
|
||||
}),
|
||||
})
|
||||
# ---
|
@ -1,5 +1,6 @@
|
||||
"""Test AirNow diagnostics."""
|
||||
from homeassistant.components.diagnostics import REDACTED
|
||||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
@ -7,41 +8,14 @@ from tests.typing import ClientSessionGenerator
|
||||
|
||||
|
||||
async def test_entry_diagnostics(
|
||||
hass: HomeAssistant, config_entry, hass_client: ClientSessionGenerator, setup_airnow
|
||||
hass: HomeAssistant,
|
||||
config_entry,
|
||||
hass_client: ClientSessionGenerator,
|
||||
setup_airnow,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test config entry diagnostics."""
|
||||
assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == {
|
||||
"entry": {
|
||||
"entry_id": config_entry.entry_id,
|
||||
"version": 1,
|
||||
"domain": "airnow",
|
||||
"title": REDACTED,
|
||||
"data": {
|
||||
"api_key": REDACTED,
|
||||
"latitude": REDACTED,
|
||||
"longitude": REDACTED,
|
||||
"radius": 75,
|
||||
},
|
||||
"options": {},
|
||||
"pref_disable_new_entities": False,
|
||||
"pref_disable_polling": False,
|
||||
"source": "user",
|
||||
"unique_id": REDACTED,
|
||||
"disabled_by": None,
|
||||
},
|
||||
"data": {
|
||||
"O3": 0.048,
|
||||
"PM2.5": 8.9,
|
||||
"HourObserved": 15,
|
||||
"DateObserved": "2020-12-20",
|
||||
"StateCode": REDACTED,
|
||||
"ReportingArea": REDACTED,
|
||||
"Latitude": REDACTED,
|
||||
"Longitude": REDACTED,
|
||||
"PM10": 12,
|
||||
"AQI": 44,
|
||||
"Category.Number": 1,
|
||||
"Category.Name": "Good",
|
||||
"Pollutant": "O3",
|
||||
},
|
||||
}
|
||||
assert (
|
||||
await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
|
||||
== snapshot
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user