1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

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
2016-09-12 19:16:14 -07:00
committed by Ben Bangert
parent 24f1bff7f1
commit 609d7ebea5
98 changed files with 1680 additions and 1109 deletions

View File

@@ -50,7 +50,7 @@ class TestMqttEventStream(unittest.TestCase):
self.assertEqual(self.hass.bus.listeners.get('*'), None)
self.assertTrue(self.add_eventstream(pub_topic='bar'))
self.hass.pool.block_till_done()
self.hass.block_till_done()
# Verify that the event handler has been added as a listener
self.assertEqual(self.hass.bus.listeners.get('*'), 1)
@@ -60,7 +60,7 @@ class TestMqttEventStream(unittest.TestCase):
""""Test the subscription."""
sub_topic = 'foo'
self.assertTrue(self.add_eventstream(sub_topic=sub_topic))
self.hass.pool.block_till_done()
self.hass.block_till_done()
# Verify that the this entity was subscribed to the topic
mock_sub.assert_called_with(self.hass, sub_topic, ANY)
@@ -76,7 +76,7 @@ class TestMqttEventStream(unittest.TestCase):
# Add the eventstream component for publishing events
self.assertTrue(self.add_eventstream(pub_topic=pub_topic))
self.hass.pool.block_till_done()
self.hass.block_till_done()
# Reset the mock because it will have already gotten calls for the
# mqtt_eventstream state change on initialization, etc.
@@ -84,7 +84,7 @@ class TestMqttEventStream(unittest.TestCase):
# Set a state of an entity
mock_state_change_event(self.hass, State(e_id, 'on'))
self.hass.pool.block_till_done()
self.hass.block_till_done()
# The order of the JSON is indeterminate,
# so first just check that publish was called
@@ -112,7 +112,7 @@ class TestMqttEventStream(unittest.TestCase):
def test_time_event_does_not_send_message(self, mock_pub):
""""Test the sending of a new message if time event."""
self.assertTrue(self.add_eventstream(pub_topic='bar'))
self.hass.pool.block_till_done()
self.hass.block_till_done()
# Reset the mock because it will have already gotten calls for the
# mqtt_eventstream state change on initialization, etc.
@@ -125,17 +125,17 @@ class TestMqttEventStream(unittest.TestCase):
""""Test the receiving of the remotely fired event."""
sub_topic = 'foo'
self.assertTrue(self.add_eventstream(sub_topic=sub_topic))
self.hass.pool.block_till_done()
self.hass.block_till_done()
calls = []
self.hass.bus.listen_once('test_event', lambda _: calls.append(1))
self.hass.pool.block_till_done()
self.hass.block_till_done()
payload = json.dumps(
{'event_type': 'test_event', 'event_data': {}},
cls=JSONEncoder
)
fire_mqtt_message(self.hass, sub_topic, payload)
self.hass.pool.block_till_done()
self.hass.block_till_done()
self.assertEqual(1, len(calls))