mirror of
https://github.com/home-assistant/core.git
synced 2025-11-13 04:50:17 +00:00
Use direct service calls in tests instead of automation common (#40623)
* Use direct service calls in tests instead of automation common * Remove automation common test helpers
This commit is contained in:
@@ -5,6 +5,7 @@ import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.homeassistant.triggers import state as state_trigger
|
||||
from homeassistant.const import ATTR_ENTITY_ID, ENTITY_MATCH_ALL, SERVICE_TURN_OFF
|
||||
from homeassistant.core import Context
|
||||
from homeassistant.setup import async_setup_component
|
||||
import homeassistant.util.dt as dt_util
|
||||
@@ -16,7 +17,6 @@ from tests.common import (
|
||||
async_mock_service,
|
||||
mock_component,
|
||||
)
|
||||
from tests.components.automation import common
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -70,8 +70,12 @@ async def test_if_fires_on_entity_change(hass, calls):
|
||||
assert calls[0].context.parent_id == context.id
|
||||
assert calls[0].data["some"] == "state - test.entity - hello - world - None"
|
||||
|
||||
await common.async_turn_off(hass)
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
automation.DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: ENTITY_MATCH_ALL},
|
||||
blocking=True,
|
||||
)
|
||||
hass.states.async_set("test.entity", "planet")
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
@@ -394,8 +398,12 @@ async def test_if_not_fires_on_entities_change_with_for_after_stop(hass, calls):
|
||||
hass.states.async_set("test.entity_1", "world")
|
||||
hass.states.async_set("test.entity_2", "world")
|
||||
await hass.async_block_till_done()
|
||||
await common.async_turn_off(hass)
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
automation.DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: ENTITY_MATCH_ALL},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=10))
|
||||
await hass.async_block_till_done()
|
||||
|
||||
Reference in New Issue
Block a user