Differentiate between warnings and errors in check_config helper (#102902)
* Differentiate between warnings and errors in check_config helper * Update tests * Treat configuration errors in frontend and its dependencies as errors * Improve test coverage * Address review comments * Improve test coverage * Improve test coverage * Address review comments * Add comment
This commit is contained in:
parent
936956a430
commit
3ba8a82243
6 changed files with 290 additions and 75 deletions
|
@ -49,6 +49,7 @@ def test_bad_core_config(mock_is_file, event_loop, mock_hass_config_yaml: None)
|
|||
res = check_config.check(get_test_config_dir())
|
||||
assert res["except"].keys() == {"homeassistant"}
|
||||
assert res["except"]["homeassistant"][1] == {"unit_system": "bad"}
|
||||
assert res["warn"] == {}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("hass_config_yaml", [BASE_CONFIG + "light:\n platform: demo"])
|
||||
|
@ -62,6 +63,7 @@ def test_config_platform_valid(
|
|||
assert res["except"] == {}
|
||||
assert res["secret_cache"] == {}
|
||||
assert res["secrets"] == {}
|
||||
assert res["warn"] == {}
|
||||
assert len(res["yaml_files"]) == 1
|
||||
|
||||
|
||||
|
@ -87,9 +89,10 @@ def test_component_platform_not_found(
|
|||
# Make sure they don't exist
|
||||
res = check_config.check(get_test_config_dir())
|
||||
assert res["components"].keys() == platforms
|
||||
assert res["except"] == {check_config.ERROR_STR: [error]}
|
||||
assert res["except"] == {}
|
||||
assert res["secret_cache"] == {}
|
||||
assert res["secrets"] == {}
|
||||
assert res["warn"] == {check_config.WARNING_STR: [error]}
|
||||
assert len(res["yaml_files"]) == 1
|
||||
|
||||
|
||||
|
@ -123,6 +126,7 @@ def test_secrets(mock_is_file, event_loop, mock_hass_config_yaml: None) -> None:
|
|||
get_test_config_dir("secrets.yaml"): {"http_pw": "http://google.com"}
|
||||
}
|
||||
assert res["secrets"] == {"http_pw": "http://google.com"}
|
||||
assert res["warn"] == {}
|
||||
assert normalize_yaml_files(res) == [
|
||||
".../configuration.yaml",
|
||||
".../secrets.yaml",
|
||||
|
@ -136,13 +140,12 @@ def test_package_invalid(mock_is_file, event_loop, mock_hass_config_yaml: None)
|
|||
"""Test an invalid package."""
|
||||
res = check_config.check(get_test_config_dir())
|
||||
|
||||
assert res["except"].keys() == {"homeassistant.packages.p1.group"}
|
||||
assert res["except"]["homeassistant.packages.p1.group"][1] == {"group": ["a"]}
|
||||
assert len(res["except"]) == 1
|
||||
assert res["except"] == {}
|
||||
assert res["components"].keys() == {"homeassistant"}
|
||||
assert len(res["components"]) == 1
|
||||
assert res["secret_cache"] == {}
|
||||
assert res["secrets"] == {}
|
||||
assert res["warn"].keys() == {"homeassistant.packages.p1.group"}
|
||||
assert res["warn"]["homeassistant.packages.p1.group"][1] == {"group": ["a"]}
|
||||
assert len(res["yaml_files"]) == 1
|
||||
|
||||
|
||||
|
@ -158,4 +161,5 @@ def test_bootstrap_error(event_loop, mock_hass_config_yaml: None) -> None:
|
|||
assert res["components"] == {} # No components, load failed
|
||||
assert res["secret_cache"] == {}
|
||||
assert res["secrets"] == {}
|
||||
assert res["warn"] == {}
|
||||
assert res["yaml_files"] == {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue