Use snapshot assertion for Enphase Envoy diagnostics test (#98910)

pull/98935/head
Joost Lekkerkerker 2023-08-24 00:57:55 +02:00 committed by GitHub
parent 360d2de1e1
commit a539d851cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 23 deletions

View File

@ -24,6 +24,7 @@ def config_entry_fixture(hass: HomeAssistant, config, serial_number):
"""Define a config entry fixture."""
entry = MockConfigEntry(
domain=DOMAIN,
entry_id="45a36e55aaddb2007c5f6602e0c38e72",
title=f"Envoy {serial_number}" if serial_number else "Envoy",
unique_id=serial_number,
data=config,

View File

@ -0,0 +1,28 @@
# serializer version: 1
# name: test_entry_diagnostics
dict({
'data': dict({
'varies_by': 'firmware_version',
}),
'entry': dict({
'data': dict({
'host': '1.1.1.1',
'name': '**REDACTED**',
'password': '**REDACTED**',
'token': '**REDACTED**',
'username': '**REDACTED**',
}),
'disabled_by': None,
'domain': 'enphase_envoy',
'entry_id': '45a36e55aaddb2007c5f6602e0c38e72',
'options': dict({
}),
'pref_disable_new_entities': False,
'pref_disable_polling': False,
'source': 'user',
'title': '**REDACTED**',
'unique_id': '**REDACTED**',
'version': 1,
}),
})
# ---

View File

@ -1,5 +1,6 @@
"""Test Enphase Envoy diagnostics."""
from homeassistant.components.diagnostics import REDACTED
from syrupy import SnapshotAssertion
from homeassistant.core import HomeAssistant
from tests.components.diagnostics import get_diagnostics_for_config_entry
@ -11,27 +12,10 @@ async def test_entry_diagnostics(
config_entry,
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) == {
"entry": {
"entry_id": config_entry.entry_id,
"version": 1,
"domain": "enphase_envoy",
"title": REDACTED,
"data": {
"host": "1.1.1.1",
"name": REDACTED,
"username": REDACTED,
"password": REDACTED,
"token": REDACTED,
},
"options": {},
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"source": "user",
"unique_id": REDACTED,
"disabled_by": None,
},
"data": {"varies_by": "firmware_version"},
}
assert (
await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
== snapshot
)