Enphase Envoy refactor and extend diagnostics (#109080)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Arie Catsman 2024-03-09 22:03:07 +01:00 committed by GitHub
parent 3b0ea52167
commit 44abe329a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 3257 additions and 18 deletions

View file

@ -2,21 +2,35 @@
from syrupy import SnapshotAssertion
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from tests.components.diagnostics import get_diagnostics_for_config_entry
from tests.typing import ClientSessionGenerator
# Fields to exclude from snapshot as they change each run
TO_EXCLUDE = {
"id",
"device_id",
"via_device_id",
"last_updated",
"last_changed",
}
def limit_diagnostic_attrs(prop, path) -> bool:
"""Mark attributes to exclude from diagnostic snapshot."""
return prop in TO_EXCLUDE
async def test_entry_diagnostics(
hass: HomeAssistant,
config_entry,
config_entry: ConfigEntry,
hass_client: ClientSessionGenerator,
setup_enphase_envoy,
snapshot: SnapshotAssertion,
) -> None:
"""Test config entry diagnostics."""
assert (
await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
== snapshot
)
assert await get_diagnostics_for_config_entry(
hass, hass_client, config_entry
) == snapshot(exclude=limit_diagnostic_attrs)