mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Fix check config packages key error (#15840)
* Fix packages deletion in check_config script * The config key for packages is not present if core config validation failed. We need to do a safe dict deletion using dict.pop. * Add check_config test for bad core config
This commit is contained in:
parent
45452e510c
commit
07840f5397
@ -325,7 +325,7 @@ def check_ha_config_file(hass):
|
||||
# Merge packages
|
||||
merge_packages_config(
|
||||
hass, config, core_config.get(CONF_PACKAGES, {}), _pack_error)
|
||||
del core_config[CONF_PACKAGES]
|
||||
core_config.pop(CONF_PACKAGES, None)
|
||||
|
||||
# Ensure we have no None values after merge
|
||||
for key, value in config.items():
|
||||
|
@ -22,6 +22,12 @@ BASE_CONFIG = (
|
||||
'\n\n'
|
||||
)
|
||||
|
||||
BAD_CORE_CONFIG = (
|
||||
'homeassistant:\n'
|
||||
' unit_system: bad\n'
|
||||
'\n\n'
|
||||
)
|
||||
|
||||
|
||||
def normalize_yaml_files(check_dict):
|
||||
"""Remove configuration path from ['yaml_files']."""
|
||||
@ -47,6 +53,17 @@ class TestCheckConfig(unittest.TestCase):
|
||||
self.maxDiff = None # pylint: disable=invalid-name
|
||||
|
||||
# pylint: disable=no-self-use,invalid-name
|
||||
@patch('os.path.isfile', return_value=True)
|
||||
def test_bad_core_config(self, isfile_patch):
|
||||
"""Test a bad core config setup."""
|
||||
files = {
|
||||
YAML_CONFIG_FILE: BAD_CORE_CONFIG,
|
||||
}
|
||||
with patch_yaml_files(files):
|
||||
res = check_config.check(get_test_config_dir())
|
||||
assert res['except'].keys() == {'homeassistant'}
|
||||
assert res['except']['homeassistant'][1] == {'unit_system': 'bad'}
|
||||
|
||||
@patch('os.path.isfile', return_value=True)
|
||||
def test_config_platform_valid(self, isfile_patch):
|
||||
"""Test a valid platform setup."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user