mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Add snapshot assertion to Ambient Station (#98764)
This commit is contained in:
parent
2369964f27
commit
07ffbe82c1
@ -28,7 +28,11 @@ def config_fixture(hass):
|
||||
@pytest.fixture(name="config_entry")
|
||||
def config_entry_fixture(hass, config):
|
||||
"""Define a config entry fixture."""
|
||||
entry = MockConfigEntry(domain=DOMAIN, data=config)
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
data=config,
|
||||
entry_id="382cf7643f016fd48b3fe52163fe8877",
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
return entry
|
||||
|
||||
|
@ -0,0 +1,65 @@
|
||||
# serializer version: 1
|
||||
# name: test_entry_diagnostics
|
||||
dict({
|
||||
'entry': dict({
|
||||
'data': dict({
|
||||
'api_key': '**REDACTED**',
|
||||
'app_key': '**REDACTED**',
|
||||
}),
|
||||
'disabled_by': None,
|
||||
'domain': 'ambient_station',
|
||||
'entry_id': '382cf7643f016fd48b3fe52163fe8877',
|
||||
'options': dict({
|
||||
}),
|
||||
'pref_disable_new_entities': False,
|
||||
'pref_disable_polling': False,
|
||||
'source': 'user',
|
||||
'title': '**REDACTED**',
|
||||
'unique_id': '**REDACTED**',
|
||||
'version': 2,
|
||||
}),
|
||||
'stations': dict({
|
||||
'devices': list([
|
||||
dict({
|
||||
'apiKey': '**REDACTED**',
|
||||
'info': dict({
|
||||
'location': '**REDACTED**',
|
||||
'name': 'Side Yard',
|
||||
}),
|
||||
'lastData': dict({
|
||||
'baromabsin': 25.016,
|
||||
'baromrelin': 29.953,
|
||||
'batt_co2': 1,
|
||||
'dailyrainin': 0,
|
||||
'date': '2022-01-19T22:38:00.000Z',
|
||||
'dateutc': 1642631880000,
|
||||
'deviceId': '**REDACTED**',
|
||||
'dewPoint': 17.75,
|
||||
'dewPointin': 37,
|
||||
'eventrainin': 0,
|
||||
'feelsLike': 21,
|
||||
'feelsLikein': 69.1,
|
||||
'hourlyrainin': 0,
|
||||
'humidity': 87,
|
||||
'humidityin': 29,
|
||||
'lastRain': '2022-01-07T19:45:00.000Z',
|
||||
'maxdailygust': 9.2,
|
||||
'monthlyrainin': 0.409,
|
||||
'solarradiation': 11.62,
|
||||
'tempf': 21,
|
||||
'tempinf': 70.9,
|
||||
'totalrainin': 35.398,
|
||||
'tz': '**REDACTED**',
|
||||
'uv': 0,
|
||||
'weeklyrainin': 0,
|
||||
'winddir': 25,
|
||||
'windgustmph': 1.1,
|
||||
'windspeedmph': 0.2,
|
||||
}),
|
||||
'macAddress': '**REDACTED**',
|
||||
}),
|
||||
]),
|
||||
'method': 'subscribe',
|
||||
}),
|
||||
})
|
||||
# ---
|
@ -1,6 +1,7 @@
|
||||
"""Test Ambient PWS diagnostics."""
|
||||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.ambient_station import DOMAIN
|
||||
from homeassistant.components.diagnostics import REDACTED
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
@ -13,62 +14,12 @@ async def test_entry_diagnostics(
|
||||
hass_client: ClientSessionGenerator,
|
||||
data_station,
|
||||
setup_config_entry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test config entry diagnostics."""
|
||||
ambient = hass.data[DOMAIN][config_entry.entry_id]
|
||||
ambient.stations = data_station
|
||||
assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == {
|
||||
"entry": {
|
||||
"entry_id": config_entry.entry_id,
|
||||
"version": 2,
|
||||
"domain": "ambient_station",
|
||||
"title": REDACTED,
|
||||
"data": {"api_key": REDACTED, "app_key": REDACTED},
|
||||
"options": {},
|
||||
"pref_disable_new_entities": False,
|
||||
"pref_disable_polling": False,
|
||||
"source": "user",
|
||||
"unique_id": REDACTED,
|
||||
"disabled_by": None,
|
||||
},
|
||||
"stations": {
|
||||
"devices": [
|
||||
{
|
||||
"macAddress": REDACTED,
|
||||
"lastData": {
|
||||
"dateutc": 1642631880000,
|
||||
"tempinf": 70.9,
|
||||
"humidityin": 29,
|
||||
"baromrelin": 29.953,
|
||||
"baromabsin": 25.016,
|
||||
"tempf": 21,
|
||||
"humidity": 87,
|
||||
"winddir": 25,
|
||||
"windspeedmph": 0.2,
|
||||
"windgustmph": 1.1,
|
||||
"maxdailygust": 9.2,
|
||||
"hourlyrainin": 0,
|
||||
"eventrainin": 0,
|
||||
"dailyrainin": 0,
|
||||
"weeklyrainin": 0,
|
||||
"monthlyrainin": 0.409,
|
||||
"totalrainin": 35.398,
|
||||
"solarradiation": 11.62,
|
||||
"uv": 0,
|
||||
"batt_co2": 1,
|
||||
"feelsLike": 21,
|
||||
"dewPoint": 17.75,
|
||||
"feelsLikein": 69.1,
|
||||
"dewPointin": 37,
|
||||
"lastRain": "2022-01-07T19:45:00.000Z",
|
||||
"deviceId": REDACTED,
|
||||
"tz": REDACTED,
|
||||
"date": "2022-01-19T22:38:00.000Z",
|
||||
},
|
||||
"info": {"name": "Side Yard", "location": REDACTED},
|
||||
"apiKey": REDACTED,
|
||||
}
|
||||
],
|
||||
"method": "subscribe",
|
||||
},
|
||||
}
|
||||
assert (
|
||||
await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
|
||||
== snapshot
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user