mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 11:33:11 -04:00
Remove import violation skip from hassfest circular dependency check (#195165)
This commit is contained in:
@@ -318,9 +318,6 @@ def _check_circular_deps(
|
||||
|
||||
def _validate_circular_dependencies(integrations: dict[str, Integration]) -> None:
|
||||
for integration in integrations.values():
|
||||
if integration.domain in IGNORE_VIOLATIONS:
|
||||
continue
|
||||
|
||||
_check_circular_deps(
|
||||
integrations, integration.domain, integration, set(), deque()
|
||||
)
|
||||
|
||||
@@ -8,6 +8,7 @@ import pytest
|
||||
from script.hassfest.dependencies import (
|
||||
CORE_INTEGRATIONS,
|
||||
ImportCollector,
|
||||
_validate_circular_dependencies,
|
||||
_validate_dependencies,
|
||||
)
|
||||
|
||||
@@ -133,6 +134,60 @@ def test_dependency_on_non_core_integration_allowed(config: Config) -> None:
|
||||
assert consumer.errors == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"domain",
|
||||
[
|
||||
pytest.param("consumer", id="regular"),
|
||||
pytest.param("logbook", id="import_check_exempt"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.parametrize(
|
||||
("manifest_key", "error"),
|
||||
[
|
||||
pytest.param(
|
||||
"dependencies",
|
||||
"Found a circular dependency with other ({domain}, other)",
|
||||
id="dependencies",
|
||||
),
|
||||
pytest.param(
|
||||
"after_dependencies",
|
||||
"Found a circular dependency with after dependencies of other"
|
||||
" ({domain}, other)",
|
||||
id="after_dependencies",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_circular_dependency_rejected(
|
||||
config: Config, domain: str, manifest_key: str, error: str
|
||||
) -> None:
|
||||
"""Test that a circular dependency is rejected."""
|
||||
integration = get_integration(domain, config)
|
||||
integration.manifest["dependencies"] = ["other"]
|
||||
other = get_integration("other", config)
|
||||
other.manifest[manifest_key] = [domain]
|
||||
|
||||
_validate_circular_dependencies({domain: integration, "other": other})
|
||||
|
||||
assert [err.error for err in integration.errors] == [error.format(domain=domain)]
|
||||
|
||||
|
||||
def test_no_circular_dependency_allowed(config: Config) -> None:
|
||||
"""Test that a dependency chain without a cycle is not rejected."""
|
||||
consumer = get_integration("consumer", config)
|
||||
consumer.manifest["dependencies"] = ["other"]
|
||||
other = get_integration("other", config)
|
||||
other.manifest["after_dependencies"] = ["third"]
|
||||
integrations = {
|
||||
"consumer": consumer,
|
||||
"other": other,
|
||||
"third": get_integration("third", config),
|
||||
}
|
||||
|
||||
_validate_circular_dependencies(integrations)
|
||||
|
||||
assert [integration.errors for integration in integrations.values()] == [[], [], []]
|
||||
|
||||
|
||||
def test_core_integrations_in_sync_with_bootstrap() -> None:
|
||||
"""Test the duplicated CORE_INTEGRATIONS stays aligned with bootstrap."""
|
||||
# Imported here so the rest of the hassfest tests are not slowed down
|
||||
|
||||
Reference in New Issue
Block a user