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
This commit is contained in:
Paulus Schoutsen authored and Ben Bangert committed 2016-09-12 19:16:14 -07:00
1 parent 24f1bff7f1
commit 609d7ebea5
98 files changed
+1680 -1109

No files matched your search

+10 -10
View File
@@ -85,7 +85,7 @@ class TestComponentsGroup(unittest.TestCase):
test_group = group.Group(
self.hass, 'init_group', ['light.Bowl', 'light.Ceiling'], False)
self.hass.pool.block_till_done()
self.hass.block_till_done()
group_state = self.hass.states.get(test_group.entity_id)
self.assertEqual(STATE_OFF, group_state.state)
@@ -99,7 +99,7 @@ class TestComponentsGroup(unittest.TestCase):
# Turn one on
self.hass.states.set('light.Ceiling', STATE_ON)
self.hass.pool.block_till_done()
self.hass.block_till_done()
group_state = self.hass.states.get(test_group.entity_id)
self.assertEqual(STATE_ON, group_state.state)
@@ -113,7 +113,7 @@ class TestComponentsGroup(unittest.TestCase):
self.assertTrue(group.is_on(self.hass, test_group.entity_id))
self.hass.states.set('light.Bowl', STATE_OFF)
self.hass.pool.block_till_done()
self.hass.block_till_done()
self.assertFalse(group.is_on(self.hass, test_group.entity_id))
# Try on non existing state
@@ -193,7 +193,7 @@ class TestComponentsGroup(unittest.TestCase):
self.hass.states.set('light.not_there_1', STATE_ON)
self.hass.pool.block_till_done()
self.hass.block_till_done()
group_state = self.hass.states.get(test_group.entity_id)
self.assertEqual(STATE_ON, group_state.state)
@@ -209,7 +209,7 @@ class TestComponentsGroup(unittest.TestCase):
self.hass.states.set('light.not_there_1', STATE_OFF)
self.hass.pool.block_till_done()
self.hass.block_till_done()
group_state = self.hass.states.get(test_group.entity_id)
self.assertEqual(STATE_OFF, group_state.state)
@@ -288,13 +288,13 @@ class TestComponentsGroup(unittest.TestCase):
self.hass.states.set('light.Bowl', STATE_ON, {
ATTR_ASSUMED_STATE: True
})
self.hass.pool.block_till_done()
self.hass.block_till_done()
state = self.hass.states.get(test_group.entity_id)
self.assertTrue(state.attributes.get(ATTR_ASSUMED_STATE))
self.hass.states.set('light.Bowl', STATE_ON)
self.hass.pool.block_till_done()
self.hass.block_till_done()
state = self.hass.states.get(test_group.entity_id)
self.assertIsNone(state.attributes.get(ATTR_ASSUMED_STATE))
@@ -303,12 +303,12 @@ class TestComponentsGroup(unittest.TestCase):
"""Test group state when device tracker in group changes zone."""
self.hass.states.set('device_tracker.Adam', STATE_HOME)
self.hass.states.set('device_tracker.Eve', STATE_NOT_HOME)
self.hass.pool.block_till_done()
self.hass.block_till_done()
group.Group(
self.hass, 'peeps',
['device_tracker.Adam', 'device_tracker.Eve'])
self.hass.states.set('device_tracker.Adam', 'cool_state_not_home')
self.hass.pool.block_till_done()
self.hass.block_till_done()
self.assertEqual(STATE_NOT_HOME,
self.hass.states.get(
group.ENTITY_ID_FORMAT.format('peeps')).state)
@@ -338,7 +338,7 @@ class TestComponentsGroup(unittest.TestCase):
'view': True,
}}}):
group.reload(self.hass)
self.hass.pool.block_till_done()
self.hass.block_till_done()
assert self.hass.states.entity_ids() == ['group.hello']
assert self.hass.bus.listeners['state_changed'] == 1