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

+2 -2
View File
@@ -38,12 +38,12 @@ class TestSensorMQTT(unittest.TestCase):
self.assertEqual(STATE_OFF, state.state)
fire_mqtt_message(self.hass, 'test-topic', 'ON')
self.hass.pool.block_till_done()
self.hass.block_till_done()
state = self.hass.states.get('binary_sensor.test')
self.assertEqual(STATE_ON, state.state)
fire_mqtt_message(self.hass, 'test-topic', 'OFF')
self.hass.pool.block_till_done()
self.hass.block_till_done()
state = self.hass.states.get('binary_sensor.test')
self.assertEqual(STATE_OFF, state.state)
@@ -110,11 +110,11 @@ class TestBinarySensorTemplate(unittest.TestCase):
vs = template.BinarySensorTemplate(hass, 'parent', 'Parent',
'motion', '{{ 1 > 1 }}', MATCH_ALL)
vs.update_ha_state()
hass.pool.block_till_done()
hass.block_till_done()
with mock.patch.object(vs, 'update') as mock_update:
hass.bus.fire(EVENT_STATE_CHANGED)
hass.pool.block_till_done()
hass.block_till_done()
try:
assert mock_update.call_count == 1
finally:
+16 -16
View File
@@ -30,9 +30,9 @@ class TestTrendBinarySensor:
})
self.hass.states.set('sensor.test_state', '1')
self.hass.pool.block_till_done()
self.hass.block_till_done()
self.hass.states.set('sensor.test_state', '2')
self.hass.pool.block_till_done()
self.hass.block_till_done()
state = self.hass.states.get('binary_sensor.test_trend_sensor')
assert state.state == 'on'
@@ -51,9 +51,9 @@ class TestTrendBinarySensor:
})
self.hass.states.set('sensor.test_state', '2')
self.hass.pool.block_till_done()
self.hass.block_till_done()
self.hass.states.set('sensor.test_state', '1')
self.hass.pool.block_till_done()
self.hass.block_till_done()
state = self.hass.states.get('binary_sensor.test_trend_sensor')
assert state.state == 'off'
@@ -73,9 +73,9 @@ class TestTrendBinarySensor:
})
self.hass.states.set('sensor.test_state', '1')
self.hass.pool.block_till_done()
self.hass.block_till_done()
self.hass.states.set('sensor.test_state', '2')
self.hass.pool.block_till_done()
self.hass.block_till_done()
state = self.hass.states.get('binary_sensor.test_trend_sensor')
assert state.state == 'off'
@@ -95,9 +95,9 @@ class TestTrendBinarySensor:
})
self.hass.states.set('sensor.test_state', '2')
self.hass.pool.block_till_done()
self.hass.block_till_done()
self.hass.states.set('sensor.test_state', '1')
self.hass.pool.block_till_done()
self.hass.block_till_done()
state = self.hass.states.get('binary_sensor.test_trend_sensor')
assert state.state == 'on'
@@ -116,9 +116,9 @@ class TestTrendBinarySensor:
}
})
self.hass.states.set('sensor.test_state', 'State', {'attr': '1'})
self.hass.pool.block_till_done()
self.hass.block_till_done()
self.hass.states.set('sensor.test_state', 'State', {'attr': '2'})
self.hass.pool.block_till_done()
self.hass.block_till_done()
state = self.hass.states.get('binary_sensor.test_trend_sensor')
assert state.state == 'on'
@@ -138,10 +138,10 @@ class TestTrendBinarySensor:
})
self.hass.states.set('sensor.test_state', 'State', {'attr': '2'})
self.hass.pool.block_till_done()
self.hass.block_till_done()
self.hass.states.set('sensor.test_state', 'State', {'attr': '1'})
self.hass.pool.block_till_done()
self.hass.block_till_done()
state = self.hass.states.get('binary_sensor.test_trend_sensor')
assert state.state == 'off'
@@ -160,9 +160,9 @@ class TestTrendBinarySensor:
})
self.hass.states.set('sensor.test_state', 'Non')
self.hass.pool.block_till_done()
self.hass.block_till_done()
self.hass.states.set('sensor.test_state', 'Numeric')
self.hass.pool.block_till_done()
self.hass.block_till_done()
state = self.hass.states.get('binary_sensor.test_trend_sensor')
assert state.state == 'off'
@@ -182,10 +182,10 @@ class TestTrendBinarySensor:
})
self.hass.states.set('sensor.test_state', 'State', {'attr': '2'})
self.hass.pool.block_till_done()
self.hass.block_till_done()
self.hass.states.set('sensor.test_state', 'State', {'attr': '1'})
self.hass.pool.block_till_done()
self.hass.block_till_done()
state = self.hass.states.get('binary_sensor.test_trend_sensor')
assert state.state == 'off'