hass-core/tests/components/sensor/test_random.py
Paulus Schoutsen 7f699b4261 Lazy initialise the worker pool (#4110)
* Lazy initialise the worker pool

* Minimize pool initialization in core tests

* Fix tests on Python 3.4

* Remove passing in thread count to mock HASS

* Tests: Allow pool by default for threaded, disable for async

* Remove JobPriority for thread pool

* Fix wrong block_till_done

* EmulatedHue: Remove unused test code

* Zigbee: do not touch hass.pool

* Init loop in add_job

* Fix core test

* Fix random sensor test
2016-10-31 08:47:29 -07:00

36 lines
1 KiB
Python

"""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.assertGreaterEqual(int(state.state), config['sensor']['minimum'])