Spread async love (#3575)

* Convert Entity.update_ha_state to be async

* Make Service.call async

* Update entity.py

* Add Entity.async_update

* Make automation zone trigger async

* Fix linting

* Reduce flakiness in hass.block_till_done

* Make automation.numeric_state async

* Make mqtt.subscribe async

* Make automation.mqtt async

* Make automation.time async

* Make automation.sun async

* Add async_track_point_in_utc_time

* Make helpers.track_sunrise/set async

* Add async_track_state_change

* Make automation.state async

* Clean up helpers/entity.py tests

* Lint

* Lint

* Core.is_state and Core.is_state_attr are async friendly

* Lint

* Lint
This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2016-09-30 12:57:24 -07:00
1 parent 7e50ccd32a
commit b650b2b0db
17 files changed
+323 -151

No files matched your search

+2 -1
View File
@@ -77,7 +77,8 @@ class TestComponentsCore(unittest.TestCase):
service_call = ha.ServiceCall('homeassistant', 'turn_on', {
'entity_id': ['light.test', 'sensor.bla', 'light.bla']
})
self.hass.services._services['homeassistant']['turn_on'](service_call)
service = self.hass.services._services['homeassistant']['turn_on']
service.func(service_call)
self.assertEqual(2, mock_call.call_count)
self.assertEqual(
+8 -5
View File
@@ -1,7 +1,8 @@
"""The tests for the logbook component."""
# pylint: disable=protected-access,too-many-public-methods
import unittest
from datetime import timedelta
import unittest
from unittest.mock import patch
from homeassistant.components import sun
import homeassistant.core as ha
@@ -18,13 +19,17 @@ from tests.common import mock_http_component, get_test_home_assistant
class TestComponentLogbook(unittest.TestCase):
"""Test the History component."""
EMPTY_CONFIG = logbook.CONFIG_SCHEMA({ha.DOMAIN: {}, logbook.DOMAIN: {}})
EMPTY_CONFIG = logbook.CONFIG_SCHEMA({logbook.DOMAIN: {}})
def setUp(self):
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
mock_http_component(self.hass)
assert setup_component(self.hass, logbook.DOMAIN, self.EMPTY_CONFIG)
self.hass.config.components += ['frontend', 'recorder', 'api']
with patch('homeassistant.components.logbook.'
'register_built_in_panel'):
assert setup_component(self.hass, logbook.DOMAIN,
self.EMPTY_CONFIG)
def tearDown(self):
"""Stop everything that was started."""
@@ -44,7 +49,6 @@ class TestComponentLogbook(unittest.TestCase):
logbook.ATTR_DOMAIN: 'switch',
logbook.ATTR_ENTITY_ID: 'switch.test_switch'
}, True)
self.hass.block_till_done()
self.assertEqual(1, len(calls))
last_call = calls[-1]
@@ -65,7 +69,6 @@ class TestComponentLogbook(unittest.TestCase):
self.hass.bus.listen(logbook.EVENT_LOGBOOK_ENTRY, event_listener)
self.hass.services.call(logbook.DOMAIN, 'log', {}, True)
self.hass.block_till_done()
self.assertEqual(0, len(calls))