mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Use snapshot assertion for Airvisual diagnostics (#98728)
This commit is contained in:
parent
c0bb3dd6e0
commit
973928ffe9
@ -69,6 +69,7 @@ def config_entry_fixture(hass, config, config_entry_version, integration_type):
|
|||||||
"""Define a config entry fixture."""
|
"""Define a config entry fixture."""
|
||||||
entry = MockConfigEntry(
|
entry = MockConfigEntry(
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
|
entry_id="3bd2acb0e4f0476d40865546d0d91921",
|
||||||
unique_id=async_get_geography_id(config),
|
unique_id=async_get_geography_id(config),
|
||||||
data={**config, CONF_INTEGRATION_TYPE: integration_type},
|
data={**config, CONF_INTEGRATION_TYPE: integration_type},
|
||||||
options={CONF_SHOW_ON_MAP: True},
|
options={CONF_SHOW_ON_MAP: True},
|
||||||
|
52
tests/components/airvisual/snapshots/test_diagnostics.ambr
Normal file
52
tests/components/airvisual/snapshots/test_diagnostics.ambr
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
# serializer version: 1
|
||||||
|
# name: test_entry_diagnostics
|
||||||
|
dict({
|
||||||
|
'data': dict({
|
||||||
|
'city': '**REDACTED**',
|
||||||
|
'country': '**REDACTED**',
|
||||||
|
'current': dict({
|
||||||
|
'pollution': dict({
|
||||||
|
'aqicn': 18,
|
||||||
|
'aqius': 52,
|
||||||
|
'maincn': 'p2',
|
||||||
|
'mainus': 'p2',
|
||||||
|
'ts': '2021-09-04T00:00:00.000Z',
|
||||||
|
}),
|
||||||
|
'weather': dict({
|
||||||
|
'hu': 45,
|
||||||
|
'ic': '10d',
|
||||||
|
'pr': 999,
|
||||||
|
'tp': 23,
|
||||||
|
'ts': '2021-09-03T21:00:00.000Z',
|
||||||
|
'wd': 252,
|
||||||
|
'ws': 0.45,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
'location': dict({
|
||||||
|
'coordinates': '**REDACTED**',
|
||||||
|
'type': 'Point',
|
||||||
|
}),
|
||||||
|
'state': '**REDACTED**',
|
||||||
|
}),
|
||||||
|
'entry': dict({
|
||||||
|
'data': dict({
|
||||||
|
'api_key': '**REDACTED**',
|
||||||
|
'integration_type': 'Geographical Location by Latitude/Longitude',
|
||||||
|
'latitude': '**REDACTED**',
|
||||||
|
'longitude': '**REDACTED**',
|
||||||
|
}),
|
||||||
|
'disabled_by': None,
|
||||||
|
'domain': 'airvisual',
|
||||||
|
'entry_id': '3bd2acb0e4f0476d40865546d0d91921',
|
||||||
|
'options': dict({
|
||||||
|
'show_on_map': True,
|
||||||
|
}),
|
||||||
|
'pref_disable_new_entities': False,
|
||||||
|
'pref_disable_polling': False,
|
||||||
|
'source': 'user',
|
||||||
|
'title': '**REDACTED**',
|
||||||
|
'unique_id': '**REDACTED**',
|
||||||
|
'version': 3,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
# ---
|
@ -1,5 +1,6 @@
|
|||||||
"""Test AirVisual diagnostics."""
|
"""Test AirVisual diagnostics."""
|
||||||
from homeassistant.components.diagnostics import REDACTED
|
from syrupy import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||||
@ -11,49 +12,10 @@ async def test_entry_diagnostics(
|
|||||||
config_entry,
|
config_entry,
|
||||||
hass_client: ClientSessionGenerator,
|
hass_client: ClientSessionGenerator,
|
||||||
setup_config_entry,
|
setup_config_entry,
|
||||||
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test config entry diagnostics."""
|
"""Test config entry diagnostics."""
|
||||||
assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == {
|
assert (
|
||||||
"entry": {
|
await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
|
||||||
"entry_id": config_entry.entry_id,
|
== snapshot
|
||||||
"version": 3,
|
)
|
||||||
"domain": "airvisual",
|
|
||||||
"title": REDACTED,
|
|
||||||
"data": {
|
|
||||||
"integration_type": "Geographical Location by Latitude/Longitude",
|
|
||||||
"api_key": REDACTED,
|
|
||||||
"latitude": REDACTED,
|
|
||||||
"longitude": REDACTED,
|
|
||||||
},
|
|
||||||
"options": {"show_on_map": True},
|
|
||||||
"pref_disable_new_entities": False,
|
|
||||||
"pref_disable_polling": False,
|
|
||||||
"source": "user",
|
|
||||||
"unique_id": REDACTED,
|
|
||||||
"disabled_by": None,
|
|
||||||
},
|
|
||||||
"data": {
|
|
||||||
"city": REDACTED,
|
|
||||||
"state": REDACTED,
|
|
||||||
"country": REDACTED,
|
|
||||||
"location": {"type": "Point", "coordinates": REDACTED},
|
|
||||||
"current": {
|
|
||||||
"weather": {
|
|
||||||
"ts": "2021-09-03T21:00:00.000Z",
|
|
||||||
"tp": 23,
|
|
||||||
"pr": 999,
|
|
||||||
"hu": 45,
|
|
||||||
"ws": 0.45,
|
|
||||||
"wd": 252,
|
|
||||||
"ic": "10d",
|
|
||||||
},
|
|
||||||
"pollution": {
|
|
||||||
"ts": "2021-09-04T00:00:00.000Z",
|
|
||||||
"aqius": 52,
|
|
||||||
"mainus": "p2",
|
|
||||||
"aqicn": 18,
|
|
||||||
"maincn": "p2",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user