mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Fix bug in check_config when an integration is removed by its own validator (#96068)
* Raise if present is False * Fix feedback * Update homeassistant/helpers/check_config.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/helpers/check_config.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Fix tests --------- Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
parent
4e2b00a443
commit
0ba2531ca4
@ -181,7 +181,9 @@ async def async_check_ha_config_file( # noqa: C901
|
||||
if config_schema is not None:
|
||||
try:
|
||||
config = config_schema(config)
|
||||
result[domain] = config[domain]
|
||||
# Don't fail if the validator removed the domain from the config
|
||||
if domain in config:
|
||||
result[domain] = config[domain]
|
||||
except vol.Invalid as ex:
|
||||
_comp_error(ex, domain, config)
|
||||
continue
|
||||
|
@ -8,9 +8,10 @@ from homeassistant.helpers.check_config import (
|
||||
CheckConfigError,
|
||||
async_check_ha_config_file,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.requirements import RequirementsNotFound
|
||||
|
||||
from tests.common import mock_platform, patch_yaml_files
|
||||
from tests.common import MockModule, mock_integration, mock_platform, patch_yaml_files
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -246,3 +247,20 @@ bla:
|
||||
assert err.domain == "bla"
|
||||
assert err.message == "Unexpected error calling config validator: Broken"
|
||||
assert err.config == {"value": 1}
|
||||
|
||||
|
||||
async def test_removed_yaml_support(hass: HomeAssistant) -> None:
|
||||
"""Test config validation check with removed CONFIG_SCHEMA without raise if present."""
|
||||
mock_integration(
|
||||
hass,
|
||||
MockModule(
|
||||
domain="bla", config_schema=cv.removed("bla", raise_if_present=False)
|
||||
),
|
||||
False,
|
||||
)
|
||||
files = {YAML_CONFIG_FILE: BASE_CONFIG + "bla:\n platform: demo"}
|
||||
with patch("os.path.isfile", return_value=True), patch_yaml_files(files):
|
||||
res = await async_check_ha_config_file(hass)
|
||||
log_ha_config(res)
|
||||
|
||||
assert res.keys() == {"homeassistant"}
|
||||
|
Loading…
x
Reference in New Issue
Block a user