Skip to content

Commit 88f18fd

Browse files
authored
Improve loader dependency tests (home-assistant#139916)
1 parent 377e0a6 commit 88f18fd

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/test_loader.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,35 @@ async def test_circular_component_dependencies(hass: HomeAssistant) -> None:
5555
with pytest.raises(loader.CircularDependency):
5656
await loader._async_component_dependencies(hass, mod_4)
5757

58+
# Create a circular after_dependency without a hard dependency
59+
mock_integration(
60+
hass, MockModule("mod1", partial_manifest={"after_dependencies": ["mod4"]})
61+
)
62+
mod_4 = mock_integration(
63+
hass, MockModule("mod4", partial_manifest={"after_dependencies": ["mod2"]})
64+
)
65+
# this currently doesn't raise, but it should. Will be improved in a follow-up.
66+
await loader._async_component_dependencies(hass, mod_4)
67+
5868

5969
async def test_nonexistent_component_dependencies(hass: HomeAssistant) -> None:
6070
"""Test if we can detect nonexistent dependencies of components."""
6171
mod_1 = mock_integration(hass, MockModule("mod1", dependencies=["nonexistent"]))
6272
with pytest.raises(loader.IntegrationNotFound):
6373
await loader._async_component_dependencies(hass, mod_1)
74+
mod_2 = mock_integration(hass, MockModule("mod2", dependencies=["mod1"]))
75+
76+
assert not await mod_2.resolve_dependencies()
77+
assert mod_2.all_dependencies_resolved
78+
with pytest.raises(RuntimeError):
79+
mod_2.all_dependencies # noqa: B018
80+
81+
# this currently is not resolved, because intermediate results are not cached
82+
# this will be improved in a follow-up
83+
assert not mod_1.all_dependencies_resolved
84+
assert not await mod_1.resolve_dependencies()
85+
with pytest.raises(RuntimeError):
86+
mod_1.all_dependencies # noqa: B018
6487

6588

6689
def test_component_loader(hass: HomeAssistant) -> None:

0 commit comments

Comments
 (0)