Use snapshot assertion for gios diagnostics test (#98984)
parent
b0952bc54a
commit
f96c1516f8
|
@ -21,6 +21,7 @@ async def init_integration(
|
|||
title="Home",
|
||||
unique_id="123",
|
||||
data={"station_id": 123, "name": "Home"},
|
||||
entry_id="86129426118ae32020417a53712d6eef",
|
||||
)
|
||||
|
||||
indexes = json.loads(load_fixture("gios/indexes.json"))
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
{
|
||||
"aqi": {
|
||||
"name": "AQI",
|
||||
"id": null,
|
||||
"index": null,
|
||||
"value": "good"
|
||||
},
|
||||
"c6h6": {
|
||||
"name": "benzene",
|
||||
"id": 658,
|
||||
"index": "very_good",
|
||||
"value": 0.23789
|
||||
},
|
||||
"co": {
|
||||
"name": "carbon monoxide",
|
||||
"id": 660,
|
||||
"index": "good",
|
||||
"value": 251.874
|
||||
},
|
||||
"no2": {
|
||||
"name": "nitrogen dioxide",
|
||||
"id": 665,
|
||||
"index": "good",
|
||||
"value": 7.13411
|
||||
},
|
||||
"o3": {
|
||||
"name": "ozone",
|
||||
"id": 667,
|
||||
"index": "good",
|
||||
"value": 95.7768
|
||||
},
|
||||
"pm10": {
|
||||
"name": "particulate matter 10",
|
||||
"id": 14395,
|
||||
"index": "good",
|
||||
"value": 16.8344
|
||||
},
|
||||
"pm25": {
|
||||
"name": "particulate matter 2.5",
|
||||
"id": 670,
|
||||
"index": "good",
|
||||
"value": 4
|
||||
},
|
||||
"so2": {
|
||||
"name": "sulfur dioxide",
|
||||
"id": 672,
|
||||
"index": "very_good",
|
||||
"value": 4.35478
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
# serializer version: 1
|
||||
# name: test_entry_diagnostics
|
||||
dict({
|
||||
'config_entry': dict({
|
||||
'data': dict({
|
||||
'name': 'Home',
|
||||
'station_id': 123,
|
||||
}),
|
||||
'disabled_by': None,
|
||||
'domain': 'gios',
|
||||
'entry_id': '86129426118ae32020417a53712d6eef',
|
||||
'options': dict({
|
||||
}),
|
||||
'pref_disable_new_entities': False,
|
||||
'pref_disable_polling': False,
|
||||
'source': 'user',
|
||||
'title': 'Home',
|
||||
'unique_id': '123',
|
||||
'version': 1,
|
||||
}),
|
||||
'coordinator_data': dict({
|
||||
'aqi': dict({
|
||||
'id': None,
|
||||
'index': None,
|
||||
'name': 'AQI',
|
||||
'value': 'good',
|
||||
}),
|
||||
'c6h6': dict({
|
||||
'id': 658,
|
||||
'index': 'very_good',
|
||||
'name': 'benzene',
|
||||
'value': 0.23789,
|
||||
}),
|
||||
'co': dict({
|
||||
'id': 660,
|
||||
'index': 'good',
|
||||
'name': 'carbon monoxide',
|
||||
'value': 251.874,
|
||||
}),
|
||||
'no2': dict({
|
||||
'id': 665,
|
||||
'index': 'good',
|
||||
'name': 'nitrogen dioxide',
|
||||
'value': 7.13411,
|
||||
}),
|
||||
'o3': dict({
|
||||
'id': 667,
|
||||
'index': 'good',
|
||||
'name': 'ozone',
|
||||
'value': 95.7768,
|
||||
}),
|
||||
'pm10': dict({
|
||||
'id': 14395,
|
||||
'index': 'good',
|
||||
'name': 'particulate matter 10',
|
||||
'value': 16.8344,
|
||||
}),
|
||||
'pm25': dict({
|
||||
'id': 670,
|
||||
'index': 'good',
|
||||
'name': 'particulate matter 2.5',
|
||||
'value': 4,
|
||||
}),
|
||||
'so2': dict({
|
||||
'id': 672,
|
||||
'index': 'very_good',
|
||||
'name': 'sulfur dioxide',
|
||||
'value': 4.35478,
|
||||
}),
|
||||
}),
|
||||
})
|
||||
# ---
|
|
@ -1,39 +1,21 @@
|
|||
"""Test GIOS diagnostics."""
|
||||
import json
|
||||
|
||||
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.typing import ClientSessionGenerator
|
||||
|
||||
|
||||
async def test_entry_diagnostics(
|
||||
hass: HomeAssistant, hass_client: ClientSessionGenerator
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test config entry diagnostics."""
|
||||
entry = await init_integration(hass)
|
||||
|
||||
coordinator_data = json.loads(load_fixture("diagnostics_data.json", "gios"))
|
||||
|
||||
result = await get_diagnostics_for_config_entry(hass, hass_client, entry)
|
||||
|
||||
assert result["config_entry"] == {
|
||||
"entry_id": entry.entry_id,
|
||||
"version": 1,
|
||||
"domain": "gios",
|
||||
"title": "Home",
|
||||
"data": {
|
||||
"station_id": 123,
|
||||
"name": "Home",
|
||||
},
|
||||
"options": {},
|
||||
"pref_disable_new_entities": False,
|
||||
"pref_disable_polling": False,
|
||||
"source": "user",
|
||||
"unique_id": "123",
|
||||
"disabled_by": None,
|
||||
}
|
||||
assert result["coordinator_data"] == coordinator_data
|
||||
assert await get_diagnostics_for_config_entry(hass, hass_client, entry) == snapshot
|
||||
|
|
Loading…
Reference in New Issue