Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion homeassistant/components/recovery_mode/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"name": "Recovery Mode",
"codeowners": ["@home-assistant/core"],
"config_flow": false,
"dependencies": ["persistent_notification"],
"documentation": "https://www.home-assistant.io/integrations/recovery_mode",
"integration_type": "system",
"quality_scale": "internal"
Expand Down
8 changes: 8 additions & 0 deletions script/hassfest/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import multiprocessing
from pathlib import Path

from homeassistant.bootstrap import CORE_INTEGRATIONS
from homeassistant.const import Platform
from homeassistant.requirements import DISCOVERY_INTEGRATIONS
Comment thread
epenet marked this conversation as resolved.
Outdated

Expand Down Expand Up @@ -332,6 +333,13 @@ def _validate_dependencies(
"dependencies", f"Dependency {dep} does not exist"
)

if dep in CORE_INTEGRATIONS:
integration.add_error(
"dependencies",
f"Dependency {dep} is a core integration and is "
"unconditionally loaded",
)


def validate(
integrations: dict[str, Integration],
Expand Down
39 changes: 38 additions & 1 deletion tests/hassfest/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

import pytest

from script.hassfest.dependencies import ImportCollector
from script.hassfest.dependencies import ImportCollector, _validate_dependencies
from script.hassfest.model import Config

from . import get_integration


@pytest.fixture
Expand Down Expand Up @@ -90,3 +93,37 @@ def test_all_imports(mock_collector) -> None:
"child_import_field",
"renamed_absolute",
}


def test_dependency_on_core_integration_rejected(config: Config) -> None:
"""Test that depending on a core integration is rejected."""
consumer = get_integration("consumer", config)
consumer.manifest["dependencies"] = ["persistent_notification"]

integrations = {
"consumer": consumer,
"persistent_notification": get_integration("persistent_notification", config),
}

_validate_dependencies(integrations)

assert len(consumer.errors) == 1
assert (
"Dependency persistent_notification is a core integration"
in consumer.errors[0].error
)


def test_dependency_on_non_core_integration_allowed(config: Config) -> None:
"""Test that depending on a non-core integration is not rejected."""
consumer = get_integration("consumer", config)
consumer.manifest["dependencies"] = ["other"]

integrations = {
"consumer": consumer,
"other": get_integration("other", config),
}

_validate_dependencies(integrations)

assert consumer.errors == []
Loading