1
0
mirror of https://github.com/home-assistant/core.git synced 2026-07-13 17:44:45 +01:00
Files
Ajinkya Gokhale afed9c71c4 Add new energieleser integration (#172464)
Co-authored-by: Amit Krishna <218109745+amitkio@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2026-06-19 12:29:56 +02:00

90 lines
3.1 KiB
Python

"""Tests for the energieleser sensor platform."""
from unittest.mock import AsyncMock
from energieleser import GasleserDevice, WaermeleserDevice, WasserleserDevice
import pytest
from syrupy.assertion import SnapshotAssertion
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from tests.common import MockConfigEntry, snapshot_platform
async def _setup_integration(
hass: HomeAssistant,
config_entry: MockConfigEntry,
) -> None:
"""Set up the energieleser integration."""
config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
@pytest.mark.usefixtures(
"entity_registry_enabled_by_default", "mock_energieleser_client"
)
async def test_stromleser_sensors(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
mock_stromleser_config_entry: MockConfigEntry,
) -> None:
"""Test all stromleser sensors against a snapshot."""
await _setup_integration(hass, mock_stromleser_config_entry)
await snapshot_platform(
hass, entity_registry, snapshot, mock_stromleser_config_entry.entry_id
)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_gasleser_sensors(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
mock_energieleser_client: AsyncMock,
mock_gasleser_device: GasleserDevice,
mock_gasleser_config_entry: MockConfigEntry,
) -> None:
"""Test all gasleser sensors against a snapshot."""
mock_energieleser_client.get_device.return_value = mock_gasleser_device
await _setup_integration(hass, mock_gasleser_config_entry)
await snapshot_platform(
hass, entity_registry, snapshot, mock_gasleser_config_entry.entry_id
)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_waermeleser_sensors(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
mock_energieleser_client: AsyncMock,
mock_waermeleser_device: WaermeleserDevice,
mock_waermeleser_config_entry: MockConfigEntry,
) -> None:
"""Test all wärmeleser sensors against a snapshot."""
mock_energieleser_client.get_device.return_value = mock_waermeleser_device
await _setup_integration(hass, mock_waermeleser_config_entry)
await snapshot_platform(
hass, entity_registry, snapshot, mock_waermeleser_config_entry.entry_id
)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_wasserleser_sensors(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
mock_energieleser_client: AsyncMock,
mock_wasserleser_device: WasserleserDevice,
mock_wasserleser_config_entry: MockConfigEntry,
) -> None:
"""Test all wasserleser sensors against a snapshot."""
mock_energieleser_client.get_device.return_value = mock_wasserleser_device
await _setup_integration(hass, mock_wasserleser_config_entry)
await snapshot_platform(
hass, entity_registry, snapshot, mock_wasserleser_config_entry.entry_id
)