2022-10-18 16:25:07 +00:00
|
|
|
"""Test Enphase Envoy diagnostics."""
|
2024-03-08 13:50:25 +00:00
|
|
|
|
2023-08-23 22:57:55 +00:00
|
|
|
from syrupy import SnapshotAssertion
|
|
|
|
|
2024-03-09 21:03:07 +00:00
|
|
|
from homeassistant.config_entries import ConfigEntry
|
2023-02-13 08:45:11 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
2022-10-18 16:25:07 +00:00
|
|
|
|
|
|
|
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
2023-02-13 08:45:11 +00:00
|
|
|
from tests.typing import ClientSessionGenerator
|
2022-10-18 16:25:07 +00:00
|
|
|
|
2024-03-09 21:03:07 +00:00
|
|
|
# Fields to exclude from snapshot as they change each run
|
|
|
|
TO_EXCLUDE = {
|
|
|
|
"id",
|
|
|
|
"device_id",
|
|
|
|
"via_device_id",
|
|
|
|
"last_updated",
|
|
|
|
"last_changed",
|
2024-03-20 20:05:07 +00:00
|
|
|
"last_reported",
|
2024-03-09 21:03:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def limit_diagnostic_attrs(prop, path) -> bool:
|
|
|
|
"""Mark attributes to exclude from diagnostic snapshot."""
|
|
|
|
return prop in TO_EXCLUDE
|
|
|
|
|
2022-10-18 16:25:07 +00:00
|
|
|
|
2023-02-13 08:45:11 +00:00
|
|
|
async def test_entry_diagnostics(
|
|
|
|
hass: HomeAssistant,
|
2024-03-09 21:03:07 +00:00
|
|
|
config_entry: ConfigEntry,
|
2023-02-13 08:45:11 +00:00
|
|
|
hass_client: ClientSessionGenerator,
|
|
|
|
setup_enphase_envoy,
|
2023-08-23 22:57:55 +00:00
|
|
|
snapshot: SnapshotAssertion,
|
2023-02-13 08:45:11 +00:00
|
|
|
) -> None:
|
2022-10-18 16:25:07 +00:00
|
|
|
"""Test config entry diagnostics."""
|
2024-03-09 21:03:07 +00:00
|
|
|
assert await get_diagnostics_for_config_entry(
|
|
|
|
hass, hass_client, config_entry
|
|
|
|
) == snapshot(exclude=limit_diagnostic_attrs)
|