From 84f30d9ef879450521684a8962449982644ec3e8 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 28 Feb 2017 23:42:31 -0800 Subject: [PATCH] Bootstrap tweaks tests (#6326) * Update strings/fix component not found message. * Fix tests * More tweak text --- homeassistant/bootstrap.py | 18 +++++++++++------- tests/scripts/test_check_config.py | 10 +++++----- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/homeassistant/bootstrap.py b/homeassistant/bootstrap.py index db9f4600261..c0ed6db11f7 100644 --- a/homeassistant/bootstrap.py +++ b/homeassistant/bootstrap.py @@ -145,26 +145,30 @@ def _async_setup_component(hass: core.HomeAssistant, domain: Domain of component to setup. config: The Home Assistant configuration. """ - def log_error(msg): + def log_error(msg, link=True): """Log helper.""" _LOGGER.error('Setup failed for %s: %s', domain, msg) - async_notify_setup_error(hass, domain, True) + async_notify_setup_error(hass, domain, link) + + component = loader.get_component(domain) + + if not component: + log_error('Component not found.', False) + return False # Validate no circular dependencies components = loader.load_order_component(domain) # OrderedSet is empty if component or dependencies could not be resolved if not components: - log_error('Unable to resolve component or dependencies') + log_error('Unable to resolve component or dependencies.') return False - component = loader.get_component(domain) - processed_config = \ conf_util.async_process_component_config(hass, config, domain) if processed_config is None: - log_error('Invalid config') + log_error('Invalid config.') return False if not hass.config.skip_pip and hasattr(component, 'REQUIREMENTS'): @@ -234,7 +238,7 @@ def async_prepare_setup_platform(hass: core.HomeAssistant, config, domain: str, # Not found if platform is None: - log_error('Unable to find platform') + log_error('Platform not found.') return None # Already loaded diff --git a/tests/scripts/test_check_config.py b/tests/scripts/test_check_config.py index 63812e1c593..250a8ccc23a 100644 --- a/tests/scripts/test_check_config.py +++ b/tests/scripts/test_check_config.py @@ -112,7 +112,6 @@ class TestCheckConfig(unittest.TestCase): 'light': []}, res['components'] ) - res['except'].pop(check_config.ERROR_STR) self.assertDictEqual( {'light.mqtt_json': {'platform': 'mqtt_json'}}, res['except'] @@ -131,9 +130,11 @@ class TestCheckConfig(unittest.TestCase): res = check_config.check(get_test_config_dir('badcomponent.yaml')) change_yaml_files(res) self.assertDictEqual({}, res['components']) - self.assertDictEqual({check_config.ERROR_STR: - ['Component not found: beer']}, - res['except']) + self.assertDictEqual({ + check_config.ERROR_STR: [ + 'Component not found: beer', + 'Setup failed for beer: Component not found.'] + }, res['except']) self.assertDictEqual({}, res['secret_cache']) self.assertDictEqual({}, res['secrets']) self.assertListEqual(['.../badcomponent.yaml'], res['yaml_files']) @@ -144,7 +145,6 @@ class TestCheckConfig(unittest.TestCase): assert res['except'] == { check_config.ERROR_STR: [ 'Platform not found: light.beer', - 'Unable to find platform light.beer' ]} self.assertDictEqual({}, res['secret_cache']) self.assertDictEqual({}, res['secrets'])