core/tests/components/melissa/test_climate.py

47 lines
1.2 KiB
Python
Raw Normal View History

"""Test for Melissa climate component."""
2024-03-13 18:54:52 +00:00
from unittest.mock import AsyncMock
from syrupy import SnapshotAssertion
from homeassistant.components.climate import (
2024-03-13 18:54:52 +00:00
DOMAIN as CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
2019-07-31 19:25:30 +00:00
)
2024-03-13 18:54:52 +00:00
from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE
from homeassistant.core import HomeAssistant
2024-03-13 18:54:52 +00:00
import homeassistant.helpers.entity_registry as er
2024-03-13 18:54:52 +00:00
from tests.components.melissa import setup_integration
2024-03-13 18:54:52 +00:00
async def test_setup_platform(
hass: HomeAssistant, mock_melissa, snapshot: SnapshotAssertion
) -> None:
"""Test setup_platform."""
2024-03-13 18:54:52 +00:00
await setup_integration(hass)
2024-03-13 18:54:52 +00:00
assert hass.states.get("climate.melissa_12345678") == snapshot
2024-03-13 18:54:52 +00:00
async def test_actions(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
mock_melissa: AsyncMock,
) -> None:
"""Test that the switch can be turned on and off."""
await setup_integration(hass)
2024-03-13 18:54:52 +00:00
entity_id = "climate.melissa_12345678"
2024-03-13 18:54:52 +00:00
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{ATTR_ENTITY_ID: entity_id, ATTR_TEMPERATURE: 25},
blocking=True,
)
await hass.async_block_till_done()
2024-03-13 18:54:52 +00:00
assert len(mock_melissa.return_value.async_send.mock_calls) == 2