Use snapshot assertion for Forecast solar diagnostics (#98723)

This commit is contained in:
Joost Lekkerkerker 2023-08-21 11:18:18 +02:00 committed by GitHub
parent 973928ffe9
commit 8f9529d376
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 44 deletions

View file

@ -0,0 +1,44 @@
# serializer version: 1
# name: test_diagnostics
dict({
'account': dict({
'rate_limit': 60,
'timezone': 'Europe/Amsterdam',
'type': 'public',
}),
'data': dict({
'energy_current_hour': 800000,
'energy_production_today': 100000,
'energy_production_today_remaining': 50000,
'energy_production_tomorrow': 200000,
'power_production_now': 300000,
'watts': dict({
'2021-06-27T13:00:00-07:00': 10,
'2022-06-27T13:00:00-07:00': 100,
}),
'wh_days': dict({
'2021-06-27T13:00:00-07:00': 20,
'2022-06-27T13:00:00-07:00': 200,
}),
'wh_period': dict({
'2021-06-27T13:00:00-07:00': 30,
'2022-06-27T13:00:00-07:00': 300,
}),
}),
'entry': dict({
'data': dict({
'latitude': '**REDACTED**',
'longitude': '**REDACTED**',
}),
'options': dict({
'api_key': '**REDACTED**',
'azimuth': 190,
'damping': 0.5,
'declination': 30,
'inverter_size': 2000,
'modules power': 5100,
}),
'title': 'Green House',
}),
})
# ---

View file

@ -1,6 +1,6 @@
"""Tests for the diagnostics data provided by the Forecast.Solar integration.""" """Tests for the diagnostics data provided by the Forecast.Solar integration."""
from syrupy import SnapshotAssertion
from homeassistant.components.diagnostics import REDACTED
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -12,48 +12,10 @@ async def test_diagnostics(
hass: HomeAssistant, hass: HomeAssistant,
hass_client: ClientSessionGenerator, hass_client: ClientSessionGenerator,
init_integration: MockConfigEntry, init_integration: MockConfigEntry,
snapshot: SnapshotAssertion,
) -> None: ) -> None:
"""Test diagnostics.""" """Test diagnostics."""
assert await get_diagnostics_for_config_entry( assert (
hass, hass_client, init_integration await get_diagnostics_for_config_entry(hass, hass_client, init_integration)
) == { == snapshot
"entry": { )
"title": "Green House",
"data": {
"latitude": REDACTED,
"longitude": REDACTED,
},
"options": {
"api_key": REDACTED,
"declination": 30,
"azimuth": 190,
"modules power": 5100,
"damping": 0.5,
"inverter_size": 2000,
},
},
"data": {
"energy_production_today": 100000,
"energy_production_today_remaining": 50000,
"energy_production_tomorrow": 200000,
"energy_current_hour": 800000,
"power_production_now": 300000,
"watts": {
"2021-06-27T13:00:00-07:00": 10,
"2022-06-27T13:00:00-07:00": 100,
},
"wh_days": {
"2021-06-27T13:00:00-07:00": 20,
"2022-06-27T13:00:00-07:00": 200,
},
"wh_period": {
"2021-06-27T13:00:00-07:00": 30,
"2022-06-27T13:00:00-07:00": 300,
},
},
"account": {
"type": "public",
"rate_limit": 60,
"timezone": "Europe/Amsterdam",
},
}