From 6f515c06a24fff7084499be42b8963a88ff82951 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Sat, 28 Oct 2023 14:52:20 +0200 Subject: [PATCH] Add test for check_config helper (#102898) --- tests/helpers/test_check_config.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/helpers/test_check_config.py b/tests/helpers/test_check_config.py index a3fd02686ac..973dec7381e 100644 --- a/tests/helpers/test_check_config.py +++ b/tests/helpers/test_check_config.py @@ -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: - """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 files = {YAML_CONFIG_FILE: BASE_CONFIG + "light:\n platform: beer"} hass.config.recovery_mode = True @@ -173,6 +173,21 @@ async def test_platform_not_found_recovery_mode(hass: HomeAssistant) -> None: 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: """Test a valid platform setup.""" files = {YAML_CONFIG_FILE: BASE_CONFIG + ' packages:\n p1:\n group: ["a"]'}