Add test for check_config helper (#102898)

This commit is contained in:
Erik Montnemery 2023-10-28 14:52:20 +02:00 committed by GitHub
parent 7f5896bc45
commit 6f515c06a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -159,7 +159,7 @@ async def test_component_platform_not_found_2(hass: HomeAssistant) -> None:
async def test_platform_not_found_recovery_mode(hass: HomeAssistant) -> None: async def test_platform_not_found_recovery_mode(hass: HomeAssistant) -> None:
"""Test no errors if platform not found in recovery_mode.""" """Test no errors if platform not found in recovery mode."""
# Make sure they don't exist # Make sure they don't exist
files = {YAML_CONFIG_FILE: BASE_CONFIG + "light:\n platform: beer"} files = {YAML_CONFIG_FILE: BASE_CONFIG + "light:\n platform: beer"}
hass.config.recovery_mode = True hass.config.recovery_mode = True
@ -173,6 +173,21 @@ async def test_platform_not_found_recovery_mode(hass: HomeAssistant) -> None:
assert not res.errors assert not res.errors
async def test_platform_not_found_safe_mode(hass: HomeAssistant) -> None:
"""Test no errors if platform not found in safe mode."""
# Make sure they don't exist
files = {YAML_CONFIG_FILE: BASE_CONFIG + "light:\n platform: beer"}
hass.config.safe_mode = True
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", "light"}
assert res["light"] == []
assert not res.errors
async def test_package_invalid(hass: HomeAssistant) -> None: async def test_package_invalid(hass: HomeAssistant) -> None:
"""Test a valid platform setup.""" """Test a valid platform setup."""
files = {YAML_CONFIG_FILE: BASE_CONFIG + ' packages:\n p1:\n group: ["a"]'} files = {YAML_CONFIG_FILE: BASE_CONFIG + ' packages:\n p1:\n group: ["a"]'}