hass-core/tests/components/rollershutter/test_demo.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

55 lines
1.9 KiB
Python

"""The tests for the Demo roller shutter platform."""
import unittest
import homeassistant.util.dt as dt_util
from homeassistant.components.rollershutter import demo
from tests.common import fire_time_changed, get_test_home_assistant
class TestRollershutterDemo(unittest.TestCase):
"""Test the Demo roller shutter."""
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 down everything that was started."""
self.hass.stop()
def test_move_up(self):
"""Test moving the rollershutter up."""
entity = demo.DemoRollershutter(self.hass, 'test', 100)
entity.move_up()
fire_time_changed(self.hass, dt_util.utcnow())
self.hass.block_till_done()
self.assertEqual(90, entity.current_position)
def test_move_down(self):
"""Test moving the rollershutter down."""
entity = demo.DemoRollershutter(self.hass, 'test', 0)
entity.move_down()
fire_time_changed(self.hass, dt_util.utcnow())
self.hass.block_till_done()
self.assertEqual(10, entity.current_position)
def test_move_position(self):
"""Test moving the rollershutter to a specific position."""
entity = demo.DemoRollershutter(self.hass, 'test', 0)
entity.move_position(10)
fire_time_changed(self.hass, dt_util.utcnow())
self.hass.block_till_done()
self.assertEqual(10, entity.current_position)
def test_stop(self):
"""Test stopping the rollershutter."""
entity = demo.DemoRollershutter(self.hass, 'test', 0)
entity.move_down()
entity.stop()
fire_time_changed(self.hass, dt_util.utcnow())
self.hass.block_till_done()
self.assertEqual(0, entity.current_position)