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:
1 parent
24f1bff7f1
commit
609d7ebea5
98 files changed
+1680
-1109
No files matched your search
@@ -8,9 +8,8 @@ from requests.exceptions import HTTPError
|
||||
import requests_mock
|
||||
|
||||
from homeassistant.components.sensor import forecast
|
||||
from homeassistant import core as ha
|
||||
|
||||
from tests.common import load_fixture
|
||||
from tests.common import load_fixture, get_test_home_assistant
|
||||
|
||||
|
||||
class TestForecastSetup(unittest.TestCase):
|
||||
@@ -18,7 +17,7 @@ class TestForecastSetup(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
"""Initialize values for this testcase class."""
|
||||
self.hass = ha.HomeAssistant()
|
||||
self.hass = get_test_home_assistant()
|
||||
self.key = 'foo'
|
||||
self.config = {
|
||||
'api_key': 'foo',
|
||||
|
||||
@@ -22,7 +22,7 @@ class TestSensorMoldIndicator(unittest.TestCase):
|
||||
{ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS})
|
||||
self.hass.states.set('test.indoorhumidity', '50',
|
||||
{ATTR_UNIT_OF_MEASUREMENT: '%'})
|
||||
self.hass.pool.block_till_done()
|
||||
self.hass.block_till_done()
|
||||
|
||||
def tearDown(self):
|
||||
"""Stop down everything that was started."""
|
||||
@@ -112,15 +112,15 @@ class TestSensorMoldIndicator(unittest.TestCase):
|
||||
|
||||
self.hass.states.set('test.indoortemp', '30',
|
||||
{ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS})
|
||||
self.hass.pool.block_till_done()
|
||||
self.hass.block_till_done()
|
||||
assert self.hass.states.get('sensor.mold_indicator').state == '90'
|
||||
|
||||
self.hass.states.set('test.outdoortemp', '25',
|
||||
{ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS})
|
||||
self.hass.pool.block_till_done()
|
||||
self.hass.block_till_done()
|
||||
assert self.hass.states.get('sensor.mold_indicator').state == '57'
|
||||
|
||||
self.hass.states.set('test.indoorhumidity', '20',
|
||||
{ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS})
|
||||
self.hass.pool.block_till_done()
|
||||
self.hass.block_till_done()
|
||||
assert self.hass.states.get('sensor.mold_indicator').state == '23'
|
||||
@@ -33,7 +33,7 @@ class TestSensorMQTT(unittest.TestCase):
|
||||
})
|
||||
|
||||
fire_mqtt_message(self.hass, 'test-topic', '100')
|
||||
self.hass.pool.block_till_done()
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get('sensor.test')
|
||||
|
||||
self.assertEqual('100', state.state)
|
||||
@@ -54,7 +54,7 @@ class TestSensorMQTT(unittest.TestCase):
|
||||
})
|
||||
|
||||
fire_mqtt_message(self.hass, 'test-topic', '{ "val": "100" }')
|
||||
self.hass.pool.block_till_done()
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get('sensor.test')
|
||||
|
||||
self.assertEqual('100', state.state)
|
||||
@@ -73,7 +73,7 @@ class TestMQTTRoomSensor(unittest.TestCase):
|
||||
"""Test the sending of a message."""
|
||||
fire_mqtt_message(
|
||||
self.hass, topic, json.dumps(message))
|
||||
self.hass.pool.block_till_done()
|
||||
self.hass.block_till_done()
|
||||
|
||||
def assert_state(self, room):
|
||||
"""Test the assertion of a room state."""
|
||||
|
||||
@@ -33,7 +33,7 @@ class TestTemplateSensor:
|
||||
assert state.state == 'It .'
|
||||
|
||||
self.hass.states.set('sensor.test_state', 'Works')
|
||||
self.hass.pool.block_till_done()
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get('sensor.test_template_sensor')
|
||||
assert state.state == 'It Works.'
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@ import unittest
|
||||
|
||||
from homeassistant.components.sensor import wunderground
|
||||
from homeassistant.const import TEMP_CELSIUS
|
||||
from homeassistant import core as ha
|
||||
|
||||
from tests.common import get_test_home_assistant
|
||||
|
||||
VALID_CONFIG_PWS = {
|
||||
'platform': 'wunderground',
|
||||
@@ -90,7 +91,7 @@ class TestWundergroundSetup(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Initialize values for this testcase class."""
|
||||
self.DEVICES = []
|
||||
self.hass = ha.HomeAssistant()
|
||||
self.hass = get_test_home_assistant()
|
||||
self.key = 'foo'
|
||||
self.config = VALID_CONFIG_PWS
|
||||
self.lat = 37.8267
|
||||
|
||||
Reference in new issue
Block a user