From 65c6f72c9dad1a12e07227bcae7553fdc096297b Mon Sep 17 00:00:00 2001 From: Johann Kellerman Date: Sun, 11 Feb 2018 09:40:48 +0200 Subject: [PATCH] check_config check bootstrap errors (#12291) --- homeassistant/scripts/check_config.py | 7 +++++++ tests/scripts/test_check_config.py | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/homeassistant/scripts/check_config.py b/homeassistant/scripts/check_config.py index 5cfcf628ec5..ba66d7d2605 100644 --- a/homeassistant/scripts/check_config.py +++ b/homeassistant/scripts/check_config.py @@ -30,6 +30,8 @@ MOCKS = { config_util._log_pkg_error), 'logger_exception': ("homeassistant.setup._LOGGER.error", setup._LOGGER.error), + 'logger_exception_bootstrap': ("homeassistant.bootstrap._LOGGER.error", + bootstrap._LOGGER.error), } SILENCE = ( 'homeassistant.bootstrap.clear_secret_cache', @@ -229,6 +231,11 @@ def check(config_path): res['except'].setdefault(ERROR_STR, []).append(msg % params) MOCKS['logger_exception'][1](msg, *params) + def mock_logger_exception_bootstrap(msg, *params): + """Log logger.exceptions.""" + res['except'].setdefault(ERROR_STR, []).append(msg % params) + MOCKS['logger_exception_bootstrap'][1](msg, *params) + # Patches to skip functions for sil in SILENCE: PATCHES[sil] = patch(sil) diff --git a/tests/scripts/test_check_config.py b/tests/scripts/test_check_config.py index a454a5a64b4..165bf121552 100644 --- a/tests/scripts/test_check_config.py +++ b/tests/scripts/test_check_config.py @@ -212,3 +212,20 @@ class TestCheckConfig(unittest.TestCase): assert res['components'] == {} assert res['secret_cache'] == {} assert res['secrets'] == {} + + def test_bootstrap_error(self): \ + # pylint: disable=no-self-use,invalid-name + """Test a valid platform setup.""" + files = { + 'badbootstrap.yaml': BASE_CONFIG + 'automation: !include no.yaml', + } + with patch_yaml_files(files): + res = check_config.check(get_test_config_dir('badbootstrap.yaml')) + change_yaml_files(res) + + err = res['except'].pop(check_config.ERROR_STR) + assert len(err) == 1 + assert res['except'] == {} + assert res['components'] == {} + assert res['secret_cache'] == {} + assert res['secrets'] == {}