mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use snapshot for devolo Home Network diagnostics test (#94966)
This commit is contained in:
parent
a48030f5dd
commit
d804d3fca3
@ -14,7 +14,7 @@ def configure_integration(hass: HomeAssistant) -> MockConfigEntry:
|
||||
CONF_IP_ADDRESS: IP,
|
||||
CONF_PASSWORD: "test",
|
||||
}
|
||||
entry = MockConfigEntry(domain=DOMAIN, data=config)
|
||||
entry = MockConfigEntry(domain=DOMAIN, data=config, entry_id="123456")
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
return entry
|
||||
|
@ -0,0 +1,37 @@
|
||||
# serializer version: 1
|
||||
# name: test_entry_diagnostics
|
||||
dict({
|
||||
'device_info': dict({
|
||||
'device_api': True,
|
||||
'features': list([
|
||||
'intmtg1',
|
||||
'led',
|
||||
'reset',
|
||||
'restart',
|
||||
'update',
|
||||
'wifi1',
|
||||
]),
|
||||
'firmware': '5.6.1',
|
||||
'mt_number': '2730',
|
||||
'plcnet_api': True,
|
||||
'product': 'dLAN pro 1200+ WiFi ac',
|
||||
}),
|
||||
'entry': dict({
|
||||
'data': dict({
|
||||
'ip_address': '192.0.2.1',
|
||||
'password': '**REDACTED**',
|
||||
}),
|
||||
'disabled_by': None,
|
||||
'domain': 'devolo_home_network',
|
||||
'entry_id': '123456',
|
||||
'options': dict({
|
||||
}),
|
||||
'pref_disable_new_entities': False,
|
||||
'pref_disable_polling': False,
|
||||
'source': 'user',
|
||||
'title': 'Mock Title',
|
||||
'unique_id': None,
|
||||
'version': 1,
|
||||
}),
|
||||
})
|
||||
# ---
|
@ -2,14 +2,12 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.devolo_home_network.diagnostics import TO_REDACT
|
||||
from homeassistant.components.diagnostics import REDACTED
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import configure_integration
|
||||
from .const import DISCOVERY_INFO
|
||||
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
from tests.typing import ClientSessionGenerator
|
||||
@ -19,6 +17,7 @@ from tests.typing import ClientSessionGenerator
|
||||
async def test_entry_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test config entry diagnostics."""
|
||||
entry = configure_integration(hass)
|
||||
@ -27,19 +26,5 @@ async def test_entry_diagnostics(
|
||||
|
||||
assert entry.state == ConfigEntryState.LOADED
|
||||
|
||||
entry_dict = entry.as_dict()
|
||||
for key in TO_REDACT:
|
||||
entry_dict["data"][key] = REDACTED
|
||||
|
||||
result = await get_diagnostics_for_config_entry(hass, hass_client, entry)
|
||||
assert result == {
|
||||
"entry": entry_dict,
|
||||
"device_info": {
|
||||
"mt_number": DISCOVERY_INFO.properties["MT"],
|
||||
"product": DISCOVERY_INFO.properties["Product"],
|
||||
"firmware": DISCOVERY_INFO.properties["FirmwareVersion"],
|
||||
"device_api": True,
|
||||
"plcnet_api": True,
|
||||
"features": DISCOVERY_INFO.properties["Features"].split(","),
|
||||
},
|
||||
}
|
||||
assert result == snapshot
|
||||
|
Loading…
x
Reference in New Issue
Block a user