1
0
mirror of https://github.com/home-assistant/core.git synced 2026-04-17 07:34:07 +01:00
Files
core/tests/components/growatt_server/test_diagnostics.py
johanzander 69dc354669 growatt_server: add diagnostics support (#165923)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-19 11:09:25 +01:00

53 lines
1.7 KiB
Python

"""Tests for the diagnostics data provided by the Growatt Server integration."""
from unittest.mock import MagicMock
from syrupy.assertion import SnapshotAssertion
from syrupy.filters import props
from homeassistant.core import HomeAssistant
from . import setup_integration
from tests.common import MockConfigEntry
from tests.components.diagnostics import get_diagnostics_for_config_entry
from tests.typing import ClientSessionGenerator
async def test_diagnostics(
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
snapshot: SnapshotAssertion,
mock_growatt_v1_api: MagicMock,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test diagnostics for V1 API (token auth) config entry."""
await setup_integration(hass, mock_config_entry)
assert await get_diagnostics_for_config_entry(
hass,
hass_client,
mock_config_entry,
) == snapshot(exclude=props("created_at", "modified_at", "entry_id"))
async def test_diagnostics_classic_api(
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
snapshot: SnapshotAssertion,
mock_growatt_classic_api: MagicMock,
mock_config_entry_classic: MockConfigEntry,
) -> None:
"""Test diagnostics for Classic API (password auth) config entry."""
await setup_integration(hass, mock_config_entry_classic)
result = await get_diagnostics_for_config_entry(
hass,
hass_client,
mock_config_entry_classic,
)
assert result == snapshot(exclude=props("created_at", "modified_at", "entry_id"))
# Verify credentials are redacted
assert result["config_entry"]["data"]["password"] == "**REDACTED**"
assert result["config_entry"]["data"]["username"] == "**REDACTED**"