core/tests/components/random/test_sensor.py

29 lines
720 B
Python

"""The test for the random number sensor platform."""
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
async def test_random_sensor(hass: HomeAssistant) -> None:
"""Test the Random number sensor."""
config = {
"sensor": {
"platform": "random",
"name": "test",
"minimum": 10,
"maximum": 20,
}
}
assert await async_setup_component(
hass,
"sensor",
config,
)
await hass.async_block_till_done()
state = hass.states.get("sensor.test")
assert int(state.state) <= config["sensor"]["maximum"]
assert int(state.state) >= config["sensor"]["minimum"]