mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Add random number sensor (#4139)
This commit is contained in:
committed by
Paulus Schoutsen
parent
5ce9aea65d
commit
274e9799b3
36
tests/components/sensor/test_random.py
Normal file
36
tests/components/sensor/test_random.py
Normal file
@@ -0,0 +1,36 @@
|
||||
"""The test for the random number sensor platform."""
|
||||
import unittest
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
|
||||
from tests.common import get_test_home_assistant
|
||||
|
||||
|
||||
class TestRandomSensor(unittest.TestCase):
|
||||
"""Test the Random number sensor."""
|
||||
|
||||
def setup_method(self, method):
|
||||
"""Set up things to be run when tests are started."""
|
||||
self.hass = get_test_home_assistant()
|
||||
|
||||
def teardown_method(self, method):
|
||||
"""Stop everything that was started."""
|
||||
self.hass.stop()
|
||||
|
||||
def test_random_sensor(self):
|
||||
"""Test the Randowm number sensor."""
|
||||
config = {
|
||||
'sensor': {
|
||||
'platform': 'random',
|
||||
'name': 'test',
|
||||
'minimum': 10,
|
||||
'maximum': 20,
|
||||
}
|
||||
}
|
||||
|
||||
assert setup_component(self.hass, 'sensor', config)
|
||||
|
||||
state = self.hass.states.get('sensor.test')
|
||||
|
||||
self.assertLessEqual(int(state.state), config['sensor']['maximum'])
|
||||
self.assertGreater(int(state.state), config['sensor']['minimum'])
|
||||
Reference in New Issue
Block a user