mirror of
https://github.com/esphome/esphome.git
synced 2026-05-24 18:06:27 +08:00
[ci] Skip YAML anchor keys in integration fixture component extraction (#14670)
This commit is contained in:
+4
-2
@@ -705,8 +705,10 @@ def get_components_from_integration_fixtures() -> set[str]:
|
||||
if not config:
|
||||
continue
|
||||
|
||||
# Add all top-level component keys
|
||||
components.update(config.keys())
|
||||
# Add all top-level component keys (skip YAML anchor keys starting with '.')
|
||||
components.update(
|
||||
k for k in config if isinstance(k, str) and not k.startswith(".")
|
||||
)
|
||||
|
||||
# Add platform components (e.g., output.template)
|
||||
for value in config.values():
|
||||
|
||||
@@ -1057,6 +1057,30 @@ def test_get_components_from_integration_fixtures() -> None:
|
||||
assert components == expected_components
|
||||
|
||||
|
||||
def test_get_components_from_integration_fixtures_skips_yaml_anchors() -> None:
|
||||
"""Test that YAML anchor keys (starting with '.') are excluded."""
|
||||
yaml_content = {
|
||||
"sensor": [{"platform": "template", "name": "test"}],
|
||||
"esphome": {"name": "test"},
|
||||
".sensor_filters": {"filters": [{"timeout": "50ms"}]},
|
||||
".binary_filters": {"filters": [{"settle": "50ms"}]},
|
||||
}
|
||||
|
||||
mock_yaml_file = Mock()
|
||||
|
||||
with (
|
||||
patch("pathlib.Path.glob") as mock_glob,
|
||||
patch("esphome.yaml_util.load_yaml", return_value=yaml_content),
|
||||
):
|
||||
mock_glob.return_value = [mock_yaml_file]
|
||||
|
||||
components = helpers.get_components_from_integration_fixtures()
|
||||
|
||||
assert ".sensor_filters" not in components
|
||||
assert ".binary_filters" not in components
|
||||
assert components == {"sensor", "esphome", "template"}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"output,expected",
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user