core/tests/components/random/test_sensor.py

27 lines
651 B
Python
Raw Normal View History

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