mirror of
https://github.com/home-assistant/core.git
synced 2026-08-17 02:34:48 +01:00
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
"""Tests for the WattWächter Plus diagnostics."""
|
|
|
|
from unittest.mock import AsyncMock
|
|
|
|
from aio_wattwaechter import WattwaechterConnectionError
|
|
from syrupy.assertion import SnapshotAssertion
|
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
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,
|
|
mock_config_entry: MockConfigEntry,
|
|
mock_client: AsyncMock,
|
|
snapshot: SnapshotAssertion,
|
|
) -> None:
|
|
"""Test config entry diagnostics."""
|
|
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
|
await hass.async_block_till_done()
|
|
|
|
assert (
|
|
await get_diagnostics_for_config_entry(hass, hass_client, mock_config_entry)
|
|
== snapshot
|
|
)
|
|
|
|
|
|
async def test_diagnostics_system_info_unavailable(
|
|
hass: HomeAssistant,
|
|
hass_client: ClientSessionGenerator,
|
|
mock_config_entry: MockConfigEntry,
|
|
mock_client: AsyncMock,
|
|
) -> None:
|
|
"""Test diagnostics still return config and meter data without system info."""
|
|
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
|
await hass.async_block_till_done()
|
|
|
|
mock_client.system_info.side_effect = WattwaechterConnectionError("offline")
|
|
result = await get_diagnostics_for_config_entry(
|
|
hass, hass_client, mock_config_entry
|
|
)
|
|
|
|
assert result["system"] is None
|
|
assert result["meter"] is not None
|