mirror of
https://github.com/esphome/esphome.git
synced 2026-10-04 18:11:29 +00:00
[ci] Only run integration tests for changed components (#14776)
This commit is contained in:
@@ -36,6 +36,7 @@ def clear_helpers_cache() -> None:
|
||||
"""Clear cached functions before each test."""
|
||||
helpers._get_github_event_data.cache_clear()
|
||||
helpers._get_changed_files_github_actions.cache_clear()
|
||||
helpers.get_components_per_integration_fixture.cache_clear()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -1111,7 +1112,7 @@ def test_get_components_from_integration_fixtures() -> None:
|
||||
"gpio",
|
||||
}
|
||||
|
||||
mock_yaml_file = Mock()
|
||||
mock_yaml_file = Mock(stem="test_fixture")
|
||||
|
||||
with (
|
||||
patch("pathlib.Path.glob") as mock_glob,
|
||||
@@ -1133,7 +1134,7 @@ def test_get_components_from_integration_fixtures_skips_yaml_anchors() -> None:
|
||||
".binary_filters": {"filters": [{"settle": "50ms"}]},
|
||||
}
|
||||
|
||||
mock_yaml_file = Mock()
|
||||
mock_yaml_file = Mock(stem="test_fixture")
|
||||
|
||||
with (
|
||||
patch("pathlib.Path.glob") as mock_glob,
|
||||
@@ -1148,6 +1149,31 @@ def test_get_components_from_integration_fixtures_skips_yaml_anchors() -> None:
|
||||
assert components == {"sensor", "esphome", "template"}
|
||||
|
||||
|
||||
def test_get_integration_test_files_for_components_real_fixtures() -> None:
|
||||
"""Test that component changes map to the correct real integration test files.
|
||||
|
||||
This test uses real fixtures to verify the mapping stays correct
|
||||
as new tests are added.
|
||||
"""
|
||||
# modbus should include at least the modbus test
|
||||
modbus_tests = helpers.get_integration_test_files_for_components({"modbus"})
|
||||
assert "tests/integration/test_uart_mock_modbus.py" in modbus_tests
|
||||
|
||||
# ld2410 should include at least the ld2410 test
|
||||
ld2410_tests = helpers.get_integration_test_files_for_components({"ld2410"})
|
||||
assert "tests/integration/test_uart_mock_ld2410.py" in ld2410_tests
|
||||
|
||||
# syslog should include at least the syslog test
|
||||
syslog_tests = helpers.get_integration_test_files_for_components({"syslog"})
|
||||
assert "tests/integration/test_syslog.py" in syslog_tests
|
||||
|
||||
# A component not used by any fixture should return nothing
|
||||
fake_tests = helpers.get_integration_test_files_for_components(
|
||||
{"nonexistent_component_xyz"}
|
||||
)
|
||||
assert fake_tests == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"output,expected",
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user