Fix config modules being imported in the event loop (#112462)
* Fix config modules being imported in the event loop There was a late import in this integration because of the circular import. The code has been rearranged to avoid the circular imports * fixes * fixes * fix patching * make eager * remove unrelated change from this branch
This commit is contained in:
parent
f03be2fd9e
commit
3f9dbd3e25
11 changed files with 317 additions and 287 deletions
|
@ -8,6 +8,7 @@ import pytest
|
|||
|
||||
from homeassistant.bootstrap import async_setup_component
|
||||
from homeassistant.components import config
|
||||
from homeassistant.components.config import automation
|
||||
from homeassistant.const import STATE_ON, STATE_UNAVAILABLE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
@ -41,7 +42,7 @@ async def test_get_automation_config(
|
|||
setup_automation,
|
||||
) -> None:
|
||||
"""Test getting automation config."""
|
||||
with patch.object(config, "SECTIONS", ["automation"]):
|
||||
with patch.object(config, "SECTIONS", [automation]):
|
||||
await async_setup_component(hass, "config", {})
|
||||
|
||||
client = await hass_client()
|
||||
|
@ -64,7 +65,7 @@ async def test_update_automation_config(
|
|||
setup_automation,
|
||||
) -> None:
|
||||
"""Test updating automation config."""
|
||||
with patch.object(config, "SECTIONS", ["automation"]):
|
||||
with patch.object(config, "SECTIONS", [automation]):
|
||||
await async_setup_component(hass, "config", {})
|
||||
|
||||
assert sorted(hass.states.async_entity_ids("automation")) == []
|
||||
|
@ -153,7 +154,7 @@ async def test_update_automation_config_with_error(
|
|||
validation_error: str,
|
||||
) -> None:
|
||||
"""Test updating automation config with errors."""
|
||||
with patch.object(config, "SECTIONS", ["automation"]):
|
||||
with patch.object(config, "SECTIONS", [automation]):
|
||||
await async_setup_component(hass, "config", {})
|
||||
|
||||
assert sorted(hass.states.async_entity_ids("automation")) == []
|
||||
|
@ -206,7 +207,7 @@ async def test_update_automation_config_with_blueprint_substitution_error(
|
|||
validation_error: str,
|
||||
) -> None:
|
||||
"""Test updating automation config with errors."""
|
||||
with patch.object(config, "SECTIONS", ["automation"]):
|
||||
with patch.object(config, "SECTIONS", [automation]):
|
||||
await async_setup_component(hass, "config", {})
|
||||
|
||||
assert sorted(hass.states.async_entity_ids("automation")) == []
|
||||
|
@ -242,7 +243,7 @@ async def test_update_remove_key_automation_config(
|
|||
setup_automation,
|
||||
) -> None:
|
||||
"""Test updating automation config while removing a key."""
|
||||
with patch.object(config, "SECTIONS", ["automation"]):
|
||||
with patch.object(config, "SECTIONS", [automation]):
|
||||
await async_setup_component(hass, "config", {})
|
||||
|
||||
assert sorted(hass.states.async_entity_ids("automation")) == []
|
||||
|
@ -281,7 +282,7 @@ async def test_bad_formatted_automations(
|
|||
setup_automation,
|
||||
) -> None:
|
||||
"""Test that we handle automations without ID."""
|
||||
with patch.object(config, "SECTIONS", ["automation"]):
|
||||
with patch.object(config, "SECTIONS", [automation]):
|
||||
await async_setup_component(hass, "config", {})
|
||||
|
||||
assert sorted(hass.states.async_entity_ids("automation")) == []
|
||||
|
@ -347,7 +348,7 @@ async def test_delete_automation(
|
|||
|
||||
assert len(entity_registry.entities) == 2
|
||||
|
||||
with patch.object(config, "SECTIONS", ["automation"]):
|
||||
with patch.object(config, "SECTIONS", [automation]):
|
||||
assert await async_setup_component(hass, "config", {})
|
||||
|
||||
assert sorted(hass.states.async_entity_ids("automation")) == [
|
||||
|
@ -385,7 +386,7 @@ async def test_api_calls_require_admin(
|
|||
setup_automation,
|
||||
) -> None:
|
||||
"""Test cloud APIs endpoints do not work as a normal user."""
|
||||
with patch.object(config, "SECTIONS", ["automation"]):
|
||||
with patch.object(config, "SECTIONS", [automation]):
|
||||
await async_setup_component(hass, "config", {})
|
||||
|
||||
hass_config_store["automations.yaml"] = [{"id": "sun"}, {"id": "moon"}]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue