mirror of
https://github.com/home-assistant/core.git
synced 2025-07-06 21:07:08 +00:00
56 lines
1.5 KiB
Python
56 lines
1.5 KiB
Python
"""Tests for numbers."""
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
from syrupy import SnapshotAssertion
|
|
|
|
from homeassistant.components.number import (
|
|
ATTR_VALUE,
|
|
DOMAIN as NUMBER_DOMAIN,
|
|
SERVICE_SET_VALUE,
|
|
)
|
|
from homeassistant.const import ATTR_ENTITY_ID, 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_numbers(
|
|
hass: HomeAssistant,
|
|
entity_registry: er.EntityRegistry,
|
|
snapshot: SnapshotAssertion,
|
|
mock_config_entry: MockConfigEntry,
|
|
mock_client: MagicMock,
|
|
) -> None:
|
|
"""Test the Ohme sensors."""
|
|
with patch("homeassistant.components.ohme.PLATFORMS", [Platform.NUMBER]):
|
|
await setup_integration(hass, mock_config_entry)
|
|
|
|
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
|
|
|
|
|
async def test_set_number(
|
|
hass: HomeAssistant,
|
|
mock_config_entry: MockConfigEntry,
|
|
mock_client: MagicMock,
|
|
) -> None:
|
|
"""Test the number set."""
|
|
await setup_integration(hass, mock_config_entry)
|
|
|
|
await hass.services.async_call(
|
|
NUMBER_DOMAIN,
|
|
SERVICE_SET_VALUE,
|
|
service_data={
|
|
ATTR_VALUE: 100,
|
|
},
|
|
target={
|
|
ATTR_ENTITY_ID: "number.ohme_home_pro_target_percentage",
|
|
},
|
|
blocking=True,
|
|
)
|
|
|
|
assert len(mock_client.async_set_target.mock_calls) == 1
|