From 3637b086d452198d1d5b3462fe74ca015f132dfe Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 23 Feb 2017 21:18:46 -0800 Subject: [PATCH 1/3] Store persistent errors in hass (speeds up tests) --- homeassistant/bootstrap.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/homeassistant/bootstrap.py b/homeassistant/bootstrap.py index c6709aea7cccf6..cb32fc887c90a1 100644 --- a/homeassistant/bootstrap.py +++ b/homeassistant/bootstrap.py @@ -34,7 +34,7 @@ ATTR_COMPONENT = 'component' ERROR_LOG_FILENAME = 'home-assistant.log' -_PERSISTENT_ERRORS = {} +DATA_PERSISTENT_ERRORS = 'bootstrap_persistent_errors' HA_COMPONENT_URL = '[{}](https://home-assistant.io/components/{}/)' @@ -601,9 +601,14 @@ def _async_persistent_notification(hass: core.HomeAssistant, component: str, This method must be run in the event loop. """ - _PERSISTENT_ERRORS[component] = _PERSISTENT_ERRORS.get(component) or link + errors = hass.data.get(DATA_PERSISTENT_ERRORS) + + if errors is None: + errors = hass.data[DATA_PERSISTENT_ERRORS] = {} + + errors[component] = errors.get(component) or link _lst = [HA_COMPONENT_URL.format(name.replace('_', '-'), name) - if link else name for name, link in _PERSISTENT_ERRORS.items()] + if link else name for name, link in errors.items()] message = ('The following components and platforms could not be set up:\n' '* ' + '\n* '.join(list(_lst)) + '\nPlease check your config') persistent_notification.async_create( From c60af1cb58284d9872302e0742379df40957d0ae Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 23 Feb 2017 21:19:03 -0800 Subject: [PATCH 2/3] Fix sleepiq test dependency on test order --- tests/components/sensor/test_sleepiq.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/components/sensor/test_sleepiq.py b/tests/components/sensor/test_sleepiq.py index 765acb56ec9faa..2d754daa6d8724 100644 --- a/tests/components/sensor/test_sleepiq.py +++ b/tests/components/sensor/test_sleepiq.py @@ -4,6 +4,7 @@ import requests_mock +from homeassistant.bootstrap import setup_component from homeassistant.components.sensor import sleepiq from tests.components.test_sleepiq import mock_responses @@ -39,6 +40,13 @@ def test_setup(self, mock): """Test for successfully setting up the SleepIQ platform.""" mock_responses(mock) + assert setup_component(self.hass, 'sleepiq', { + 'sleepiq': { + 'username': '', + 'password': '', + } + }) + sleepiq.setup_platform(self.hass, self.config, self.add_devices, From 00177092d08c1a75d1ec0cfa77a26d682d764375 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 23 Feb 2017 21:19:36 -0800 Subject: [PATCH 3/3] Fix sleepiq validation --- homeassistant/components/sleepiq.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/sleepiq.py b/homeassistant/components/sleepiq.py index 7016cd72492c8d..610f4e79bb2a7e 100644 --- a/homeassistant/components/sleepiq.py +++ b/homeassistant/components/sleepiq.py @@ -39,7 +39,7 @@ DATA = None CONFIG_SCHEMA = vol.Schema({ - DOMAIN: vol.Schema({ + vol.Required(DOMAIN): vol.Schema({ vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, }),