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:
1 parent
35533407fe
commit
8837ed35cd
11 files changed
+156
-125
No files matched your search
@@ -4,10 +4,10 @@ from unittest import mock
|
||||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.const import ATTR_ENTITY_ID, ENTITY_MATCH_ALL, SERVICE_TURN_OFF
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import async_fire_mqtt_message, async_mock_service, mock_component
|
||||
from tests.components.automation import common
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -44,11 +44,15 @@ async def test_if_fires_on_topic_match(hass, calls):
|
||||
|
||||
async_fire_mqtt_message(hass, "test-topic", '{ "hello": "world" }')
|
||||
await hass.async_block_till_done()
|
||||
assert 1 == len(calls)
|
||||
assert len(calls) == 1
|
||||
assert 'mqtt - test-topic - { "hello": "world" } - world' == calls[0].data["some"]
|
||||
|
||||
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_mqtt_message(hass, "test-topic", "test_payload")
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
|
||||
Reference in new issue
Block a user