mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Handle integration with missing dependencies (#122386)
This commit is contained in:
parent
7ec41275d5
commit
c73e7ae178
@ -906,7 +906,13 @@ async def _async_resolve_domains_to_setup(
|
|||||||
await asyncio.gather(*resolve_dependencies_tasks)
|
await asyncio.gather(*resolve_dependencies_tasks)
|
||||||
|
|
||||||
for itg in integrations_to_process:
|
for itg in integrations_to_process:
|
||||||
for dep in itg.all_dependencies:
|
try:
|
||||||
|
all_deps = itg.all_dependencies
|
||||||
|
except RuntimeError:
|
||||||
|
# Integration.all_dependencies raises RuntimeError if
|
||||||
|
# dependencies could not be resolved
|
||||||
|
continue
|
||||||
|
for dep in all_deps:
|
||||||
if dep in domains_to_setup:
|
if dep in domains_to_setup:
|
||||||
continue
|
continue
|
||||||
domains_to_setup.add(dep)
|
domains_to_setup.add(dep)
|
||||||
|
@ -1329,6 +1329,34 @@ async def test_bootstrap_dependencies(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("load_registries", [False])
|
||||||
|
async def test_bootstrap_dependency_not_found(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
) -> None:
|
||||||
|
"""Test setup when an integration has missing dependencies."""
|
||||||
|
mock_integration(
|
||||||
|
hass,
|
||||||
|
MockModule("good_integration", dependencies=[]),
|
||||||
|
)
|
||||||
|
# Simulate an integration with missing dependencies. While a core integration
|
||||||
|
# can't have missing dependencies thanks to checks by hassfest, there's no such
|
||||||
|
# guarantee for custom integrations.
|
||||||
|
mock_integration(
|
||||||
|
hass,
|
||||||
|
MockModule("bad_integration", dependencies=["hahaha_crash_and_burn"]),
|
||||||
|
)
|
||||||
|
|
||||||
|
assert await bootstrap.async_from_config_dict(
|
||||||
|
{"good_integration": {}, "bad_integration": {}}, hass
|
||||||
|
)
|
||||||
|
|
||||||
|
assert "good_integration" in hass.config.components
|
||||||
|
assert "bad_integration" not in hass.config.components
|
||||||
|
|
||||||
|
assert "Unable to resolve dependencies for bad_integration" in caplog.text
|
||||||
|
|
||||||
|
|
||||||
async def test_pre_import_no_requirements(hass: HomeAssistant) -> None:
|
async def test_pre_import_no_requirements(hass: HomeAssistant) -> None:
|
||||||
"""Test pre-imported and do not have any requirements."""
|
"""Test pre-imported and do not have any requirements."""
|
||||||
pre_imports = [
|
pre_imports = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user