hass-core/tests/components/test_input_slider.py
Paulus Schoutsen 609d7ebea5 Migrate core from threads to async awesomeness (#3248)
* Add event loop to the core

* Add block_till_done to HA core object

* Fix some tests

* Linting core

* Fix statemachine tests

* Core test fixes

* fix block_till_done to wait for loop and queue to empty

* fix test_core for passing, and correct start/stop/block_till_done

* Fix remote tests

* Fix tests: block_till_done

* Fix linting

* Fix more tests

* Fix final linting

* Fix remote test

* remove unnecessary import

* reduce sleep to avoid slowing down the tests excessively

* fix remaining tests to wait for non-threadsafe operations

* Add async_ doc strings for event loop / coroutine info

* Fix command line test to block for the right timeout

* Fix py3.4.2 loop var access

* Fix SERVICE_CALL_LIMIT being in effect for other tests

* Fix lint errors

* Fix lint error with proper placement

* Fix slave start to not start a timer

* Add asyncio compatible listeners.

* Increase min Python version to 3.4.2

* Move async backports to util

* Add backported async tests

* Fix linting

* Simplify Python version check

* Fix lint

* Remove unneeded try/except and queue listener appproriately.

* Fix tuple vs. list unorderable error on version compare.

* Fix version tests
2016-09-12 19:16:14 -07:00

70 lines
2 KiB
Python

"""The tests for the Input slider component."""
# pylint: disable=too-many-public-methods,protected-access
import unittest
from homeassistant.components import input_slider
from tests.common import get_test_home_assistant
class TestInputSlider(unittest.TestCase):
"""Test the input slider component."""
def setUp(self): # pylint: disable=invalid-name
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
def tearDown(self): # pylint: disable=invalid-name
"""Stop everything that was started."""
self.hass.stop()
def test_config(self):
"""Test config."""
self.assertFalse(input_slider.setup(self.hass, {
'input_slider': None
}))
self.assertFalse(input_slider.setup(self.hass, {
'input_slider': {
}
}))
self.assertFalse(input_slider.setup(self.hass, {
'input_slider': {
'name with space': None
}
}))
def test_select_value(self):
"""Test select_value method."""
self.assertTrue(input_slider.setup(self.hass, {
'input_slider': {
'test_1': {
'initial': 50,
'min': 0,
'max': 100,
},
}
}))
entity_id = 'input_slider.test_1'
state = self.hass.states.get(entity_id)
self.assertEqual(50, float(state.state))
input_slider.select_value(self.hass, entity_id, '30.4')
self.hass.block_till_done()
state = self.hass.states.get(entity_id)
self.assertEqual(30.4, float(state.state))
input_slider.select_value(self.hass, entity_id, '70')
self.hass.block_till_done()
state = self.hass.states.get(entity_id)
self.assertEqual(70, float(state.state))
input_slider.select_value(self.hass, entity_id, '110')
self.hass.block_till_done()
state = self.hass.states.get(entity_id)
self.assertEqual(70, float(state.state))