mirror of
https://github.com/home-assistant/core.git
synced 2026-12-06 13:45:55 -04:00
Add tests for diagnostics in vesync (#191085)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
"""Tests for the diagnostics data provided by the VeSync integration."""
|
||||
|
||||
from types import SimpleNamespace
|
||||
|
||||
from pytest_homeassistant.components.diagnostics import (
|
||||
get_diagnostics_for_config_entry,
|
||||
get_diagnostics_for_device,
|
||||
@@ -8,6 +10,7 @@ from pytest_homeassistant.typing import ClientSessionGenerator
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
from syrupy.matchers import path_type
|
||||
|
||||
from homeassistant.components.diagnostics import REDACTED
|
||||
from homeassistant.components.vesync.const import DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
@@ -92,3 +95,38 @@ async def test_async_get_device_diagnostics__single_fan(
|
||||
regex=True,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
async def test_async_get_device_diagnostics__subdevice_redacts_values(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
hass_client: ClientSessionGenerator,
|
||||
config_entry: ConfigEntry,
|
||||
config: ConfigType,
|
||||
manager,
|
||||
fan,
|
||||
) -> None:
|
||||
"""Test sub-device matching and redaction in device diagnostics."""
|
||||
fan.sub_device_no = 7
|
||||
fan.manager = SimpleNamespace(secret="manager-secret")
|
||||
fan.uuid = "device-uuid"
|
||||
fan.mac_id = "device-mac"
|
||||
manager.devices.fans.append(fan)
|
||||
|
||||
assert await async_setup_component(hass, DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
device = device_registry.async_get_device_by_identifier(
|
||||
(DOMAIN, "fan7"), config_entry.entry_id
|
||||
)
|
||||
assert device is not None
|
||||
|
||||
manager.devices.outlets.append(SimpleNamespace(cid=None, sub_device_no=None))
|
||||
fan.state = SimpleNamespace(connection_status="online", mac_id="state-mac")
|
||||
|
||||
diag = await get_diagnostics_for_device(hass, hass_client, config_entry, device)
|
||||
|
||||
assert diag["manager"] == REDACTED
|
||||
assert diag["uuid"] == REDACTED
|
||||
assert diag["mac_id"] == REDACTED
|
||||
assert diag["state"]["mac_id"] == REDACTED
|
||||
|
||||
Reference in New Issue
Block a user