From e4bb7c93a259ff3d82c7976f268dbb00be44c0ca Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 3 Jul 2026 19:23:07 -0500 Subject: [PATCH] [store_yaml] Add coverage for gated YAML discovery in load_config --- tests/unit_tests/test_config_normalization.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/unit_tests/test_config_normalization.py b/tests/unit_tests/test_config_normalization.py index a06b2da621..f2ed406617 100644 --- a/tests/unit_tests/test_config_normalization.py +++ b/tests/unit_tests/test_config_normalization.py @@ -151,6 +151,27 @@ def test_validate_config_warns_on_dropped_merge_key( assert yaml_util.take_dropped_merge_keys() == [] +@pytest.mark.parametrize("store_yaml_enabled", [False, True]) +def test_load_config_gates_yaml_discovery_on_store_yaml( + tmp_path: Path, store_yaml_enabled: bool +) -> None: + """YAML source discovery (a second full parse) only runs when a consumer + like store_yaml is configured.""" + content = "esphome:\n name: test\nhost:\napi:\n" + if store_yaml_enabled: + content += "store_yaml:\n allow_unencrypted: true\n" + main = tmp_path / "main.yaml" + main.write_text(content) + CORE.config_path = main + + result = config.load_config({}) + + assert not result.errors + assert ("yaml_sources" in CORE.data) == store_yaml_enabled + if store_yaml_enabled: + assert main.resolve() in CORE.data["yaml_sources"].files + + def test_validate_config_suppresses_merge_warning( tmp_path: Path, caplog: pytest.LogCaptureFixture ) -> None: