Files
core/tests/components/weheat/test_diagnostics.py
T
2026-09-04 08:50:19 +02:00

51 lines
1.5 KiB
Python

"""Tests for the weheat diagnostics."""
from unittest.mock import AsyncMock
import pytest
from syrupy.assertion import SnapshotAssertion
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
@pytest.mark.usefixtures("mock_weheat_discover", "mock_weheat_heat_pump")
async def test_diagnostics(
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
mock_config_entry: MockConfigEntry,
snapshot: SnapshotAssertion,
) -> None:
"""Test the diagnostics of a config entry."""
await setup_integration(hass, mock_config_entry)
assert (
await get_diagnostics_for_config_entry(hass, hass_client, mock_config_entry)
== snapshot
)
@pytest.mark.usefixtures("mock_weheat_discover")
async def test_diagnostics_without_data(
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
mock_config_entry: MockConfigEntry,
mock_weheat_heat_pump: AsyncMock,
) -> None:
"""Test the diagnostics of a heat pump that reported nothing yet."""
mock_weheat_heat_pump.raw_content = None
await setup_integration(hass, mock_config_entry)
diagnostics = await get_diagnostics_for_config_entry(
hass, hass_client, mock_config_entry
)
assert diagnostics["heat_pumps"][0]["logs"] == {}
assert diagnostics["heat_pumps"][0]["energy"] == {}