Use snapshot assertion for ESPHome diagnostics test (#98913)
This commit is contained in:
parent
a539d851cc
commit
f1fb28aad5
3 changed files with 30 additions and 15 deletions
|
@ -62,6 +62,7 @@ def mock_config_entry(hass) -> MockConfigEntry:
|
||||||
"""Return the default mocked config entry."""
|
"""Return the default mocked config entry."""
|
||||||
config_entry = MockConfigEntry(
|
config_entry = MockConfigEntry(
|
||||||
title="ESPHome Device",
|
title="ESPHome Device",
|
||||||
|
entry_id="08d821dc059cf4f645cb024d32c8e708",
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
data={
|
data={
|
||||||
CONF_HOST: "192.168.1.2",
|
CONF_HOST: "192.168.1.2",
|
||||||
|
|
26
tests/components/esphome/snapshots/test_diagnostics.ambr
Normal file
26
tests/components/esphome/snapshots/test_diagnostics.ambr
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# serializer version: 1
|
||||||
|
# name: test_diagnostics
|
||||||
|
dict({
|
||||||
|
'config': dict({
|
||||||
|
'data': dict({
|
||||||
|
'device_name': 'test',
|
||||||
|
'host': '192.168.1.2',
|
||||||
|
'noise_psk': '**REDACTED**',
|
||||||
|
'password': '**REDACTED**',
|
||||||
|
'port': 6053,
|
||||||
|
}),
|
||||||
|
'disabled_by': None,
|
||||||
|
'domain': 'esphome',
|
||||||
|
'entry_id': '08d821dc059cf4f645cb024d32c8e708',
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'pref_disable_new_entities': False,
|
||||||
|
'pref_disable_polling': False,
|
||||||
|
'source': 'user',
|
||||||
|
'title': 'ESPHome Device',
|
||||||
|
'unique_id': '11:22:33:44:55:aa',
|
||||||
|
'version': 1,
|
||||||
|
}),
|
||||||
|
'dashboard': 'mock-slug',
|
||||||
|
})
|
||||||
|
# ---
|
|
@ -1,12 +1,8 @@
|
||||||
"""Tests for the diagnostics data provided by the ESPHome integration."""
|
"""Tests for the diagnostics data provided by the ESPHome integration."""
|
||||||
|
from syrupy import SnapshotAssertion
|
||||||
|
|
||||||
|
|
||||||
from homeassistant.components.esphome.const import CONF_DEVICE_NAME, CONF_NOISE_PSK
|
|
||||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from . import DASHBOARD_SLUG
|
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||||
from tests.typing import ClientSessionGenerator
|
from tests.typing import ClientSessionGenerator
|
||||||
|
@ -18,17 +14,9 @@ async def test_diagnostics(
|
||||||
init_integration: MockConfigEntry,
|
init_integration: MockConfigEntry,
|
||||||
enable_bluetooth: None,
|
enable_bluetooth: None,
|
||||||
mock_dashboard,
|
mock_dashboard,
|
||||||
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test diagnostics for config entry."""
|
"""Test diagnostics for config entry."""
|
||||||
result = await get_diagnostics_for_config_entry(hass, hass_client, init_integration)
|
result = await get_diagnostics_for_config_entry(hass, hass_client, init_integration)
|
||||||
|
|
||||||
assert isinstance(result, dict)
|
assert result == snapshot
|
||||||
assert result["config"]["data"] == {
|
|
||||||
CONF_DEVICE_NAME: "test",
|
|
||||||
CONF_HOST: "192.168.1.2",
|
|
||||||
CONF_PORT: 6053,
|
|
||||||
CONF_PASSWORD: "**REDACTED**",
|
|
||||||
CONF_NOISE_PSK: "**REDACTED**",
|
|
||||||
}
|
|
||||||
assert result["config"]["unique_id"] == "11:22:33:44:55:aa"
|
|
||||||
assert result["dashboard"] == DASHBOARD_SLUG
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue