1
0
mirror of https://github.com/home-assistant/core.git synced 2026-02-26 12:55:16 +00:00
Files
core/tests/components/imeon_inverter/test_select.py
Imeon-Energy d5132e8ea9 Add select to Imeon inverter integration (#150889)
Co-authored-by: TheBushBoy <theodavid@icloud.com>
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
Co-authored-by: Norbert Rittel <norbert@rittel.de>
2025-09-11 17:55:55 +02:00

56 lines
1.6 KiB
Python

"""Test the Imeon Inverter selects."""
from unittest.mock import MagicMock, patch
from freezegun.api import FrozenDateTimeFactory
from syrupy.assertion import SnapshotAssertion
from homeassistant.components.select import DOMAIN as SELECT_DOMAIN
from homeassistant.const import (
ATTR_ENTITY_ID,
ATTR_OPTION,
SERVICE_SELECT_OPTION,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import setup_integration
from tests.common import MockConfigEntry, snapshot_platform
async def test_selects(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test the Imeon Inverter selects."""
with patch("homeassistant.components.imeon_inverter.PLATFORMS", [Platform.SELECT]):
await setup_integration(hass, mock_config_entry)
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
async def test_select_mode(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_imeon_inverter: MagicMock,
freezer: FrozenDateTimeFactory,
) -> None:
"""Test select mode updates entity state."""
mock_config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
entity_id = "sensor.imeon_inverter_inverter_mode"
assert entity_id
await hass.services.async_call(
SELECT_DOMAIN,
SERVICE_SELECT_OPTION,
{ATTR_ENTITY_ID: entity_id, ATTR_OPTION: "smart_grid"},
blocking=True,
)