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:
Erik Montnemery 2023-11-05 03:08:04 +01:00 committed by GitHub
parent 936956a430
commit 3ba8a82243
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 290 additions and 75 deletions

View file

@ -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"] == {}