Bootstrap tweaks tests (#6326)

* Update strings/fix component not found message.

* Fix tests

* More tweak text
This commit is contained in:
Paulus Schoutsen 2017-02-28 23:42:31 -08:00 committed by GitHub
parent ac49298c8d
commit 84f30d9ef8
2 changed files with 16 additions and 12 deletions

View File

@ -145,26 +145,30 @@ def _async_setup_component(hass: core.HomeAssistant,
domain: Domain of component to setup. domain: Domain of component to setup.
config: The Home Assistant configuration. config: The Home Assistant configuration.
""" """
def log_error(msg): def log_error(msg, link=True):
"""Log helper.""" """Log helper."""
_LOGGER.error('Setup failed for %s: %s', domain, msg) _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 # Validate no circular dependencies
components = loader.load_order_component(domain) components = loader.load_order_component(domain)
# OrderedSet is empty if component or dependencies could not be resolved # OrderedSet is empty if component or dependencies could not be resolved
if not components: if not components:
log_error('Unable to resolve component or dependencies') log_error('Unable to resolve component or dependencies.')
return False return False
component = loader.get_component(domain)
processed_config = \ processed_config = \
conf_util.async_process_component_config(hass, config, domain) conf_util.async_process_component_config(hass, config, domain)
if processed_config is None: if processed_config is None:
log_error('Invalid config') log_error('Invalid config.')
return False return False
if not hass.config.skip_pip and hasattr(component, 'REQUIREMENTS'): 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 # Not found
if platform is None: if platform is None:
log_error('Unable to find platform') log_error('Platform not found.')
return None return None
# Already loaded # Already loaded

View File

@ -112,7 +112,6 @@ class TestCheckConfig(unittest.TestCase):
'light': []}, 'light': []},
res['components'] res['components']
) )
res['except'].pop(check_config.ERROR_STR)
self.assertDictEqual( self.assertDictEqual(
{'light.mqtt_json': {'platform': 'mqtt_json'}}, {'light.mqtt_json': {'platform': 'mqtt_json'}},
res['except'] res['except']
@ -131,9 +130,11 @@ class TestCheckConfig(unittest.TestCase):
res = check_config.check(get_test_config_dir('badcomponent.yaml')) res = check_config.check(get_test_config_dir('badcomponent.yaml'))
change_yaml_files(res) change_yaml_files(res)
self.assertDictEqual({}, res['components']) self.assertDictEqual({}, res['components'])
self.assertDictEqual({check_config.ERROR_STR: self.assertDictEqual({
['Component not found: beer']}, check_config.ERROR_STR: [
res['except']) 'Component not found: beer',
'Setup failed for beer: Component not found.']
}, res['except'])
self.assertDictEqual({}, res['secret_cache']) self.assertDictEqual({}, res['secret_cache'])
self.assertDictEqual({}, res['secrets']) self.assertDictEqual({}, res['secrets'])
self.assertListEqual(['.../badcomponent.yaml'], res['yaml_files']) self.assertListEqual(['.../badcomponent.yaml'], res['yaml_files'])
@ -144,7 +145,6 @@ class TestCheckConfig(unittest.TestCase):
assert res['except'] == { assert res['except'] == {
check_config.ERROR_STR: [ check_config.ERROR_STR: [
'Platform not found: light.beer', 'Platform not found: light.beer',
'Unable to find platform light.beer'
]} ]}
self.assertDictEqual({}, res['secret_cache']) self.assertDictEqual({}, res['secret_cache'])
self.assertDictEqual({}, res['secrets']) self.assertDictEqual({}, res['secrets'])