Skip to content

Commit

Permalink
Only raise missing integration issue for config entry integrations (h…
Browse files Browse the repository at this point in the history
  • Loading branch information
joostlek authored Sep 24, 2024
1 parent ffa76df commit c1781cd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion homeassistant/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ async def _async_setup_component(
integration = await loader.async_get_integration(hass, domain)
except loader.IntegrationNotFound:
_log_error_setup_error(hass, domain, None, "Integration not found.")
if not hass.config.safe_mode:
if not hass.config.safe_mode and hass.config_entries.async_entries(domain):
ir.async_create_issue(
hass,
HOMEASSISTANT_DOMAIN,
Expand Down
2 changes: 2 additions & 0 deletions tests/components/homeassistant/test_repairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ async def test_integration_not_found_confirm_step(
await hass.async_block_till_done()
assert await async_setup_component(hass, REPAIRS_DOMAIN, {REPAIRS_DOMAIN: {}})
await hass.async_block_till_done()
MockConfigEntry(domain="test1").add_to_hass(hass)
assert await async_setup_component(hass, "test1", {}) is False
await hass.async_block_till_done()
entry1 = MockConfigEntry(domain="test1")
Expand Down Expand Up @@ -83,6 +84,7 @@ async def test_integration_not_found_ignore_step(
await hass.async_block_till_done()
assert await async_setup_component(hass, REPAIRS_DOMAIN, {REPAIRS_DOMAIN: {}})
await hass.async_block_till_done()
MockConfigEntry(domain="test1").add_to_hass(hass)
assert await async_setup_component(hass, "test1", {}) is False
await hass.async_block_till_done()
entry1 = MockConfigEntry(domain="test1")
Expand Down
27 changes: 22 additions & 5 deletions tests/test_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,22 +248,39 @@ async def test_component_not_found(
hass: HomeAssistant, issue_registry: IssueRegistry
) -> None:
"""setup_component should raise a repair issue if component doesn't exist."""
MockConfigEntry(domain="non_existing").add_to_hass(hass)
assert await setup.async_setup_component(hass, "non_existing", {}) is False
assert len(issue_registry.issues) == 1
issue = issue_registry.async_get_issue(
HOMEASSISTANT_DOMAIN, "integration_not_found.non_existing"
)
assert issue
assert issue.translation_key == "integration_not_found"
assert (
HOMEASSISTANT_DOMAIN,
"integration_not_found.non_existing",
) in issue_registry.issues


async def test_yaml_component_not_found(
hass: HomeAssistant, issue_registry: IssueRegistry
) -> None:
"""setup_component should only raise an exception for missing config entry integrations."""
assert await setup.async_setup_component(hass, "non_existing", {}) is False
assert len(issue_registry.issues) == 0
assert (
HOMEASSISTANT_DOMAIN,
"integration_not_found.non_existing",
) not in issue_registry.issues


async def test_component_missing_not_raising_in_safe_mode(
hass: HomeAssistant, issue_registry: IssueRegistry
) -> None:
"""setup_component should not raise an issue if component doesn't exist in safe."""
MockConfigEntry(domain="non_existing").add_to_hass(hass)
hass.config.safe_mode = True
assert await setup.async_setup_component(hass, "non_existing", {}) is False
assert len(issue_registry.issues) == 0
assert (
HOMEASSISTANT_DOMAIN,
"integration_not_found.non_existing",
) not in issue_registry.issues


async def test_component_not_double_initialized(hass: HomeAssistant) -> None:
Expand Down

0 comments on commit c1781cd

Please sign in to comment.