mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use service_calls fixture in lcn tests (#120931)
This commit is contained in:
parent
c8bb64882e
commit
ce54ca9c8e
@ -12,11 +12,10 @@ import pytest
|
|||||||
from homeassistant.components.lcn.const import DOMAIN
|
from homeassistant.components.lcn.const import DOMAIN
|
||||||
from homeassistant.components.lcn.helpers import generate_unique_id
|
from homeassistant.components.lcn.helpers import generate_unique_id
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall
|
|
||||||
from homeassistant.helpers import device_registry as dr
|
from homeassistant.helpers import device_registry as dr
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import MockConfigEntry, async_mock_service, load_fixture
|
from tests.common import MockConfigEntry, load_fixture
|
||||||
|
|
||||||
|
|
||||||
class MockModuleConnection(ModuleConnection):
|
class MockModuleConnection(ModuleConnection):
|
||||||
@ -78,12 +77,6 @@ def create_config_entry(name):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def calls(hass: HomeAssistant) -> list[ServiceCall]:
|
|
||||||
"""Track calls to a mock service."""
|
|
||||||
return async_mock_service(hass, "test", "automation")
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="entry")
|
@pytest.fixture(name="entry")
|
||||||
def create_config_entry_pchk():
|
def create_config_entry_pchk():
|
||||||
"""Return one specific config entry."""
|
"""Return one specific config entry."""
|
||||||
|
@ -72,7 +72,7 @@ async def test_get_triggers_non_module_device(
|
|||||||
|
|
||||||
|
|
||||||
async def test_if_fires_on_transponder_event(
|
async def test_if_fires_on_transponder_event(
|
||||||
hass: HomeAssistant, calls: list[ServiceCall], entry, lcn_connection
|
hass: HomeAssistant, service_calls: list[ServiceCall], entry, lcn_connection
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for transponder event triggers firing."""
|
"""Test for transponder event triggers firing."""
|
||||||
address = (0, 7, False)
|
address = (0, 7, False)
|
||||||
@ -111,15 +111,15 @@ async def test_if_fires_on_transponder_event(
|
|||||||
await lcn_connection.async_process_input(inp)
|
await lcn_connection.async_process_input(inp)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(calls) == 1
|
assert len(service_calls) == 1
|
||||||
assert calls[0].data == {
|
assert service_calls[0].data == {
|
||||||
"test": "test_trigger_transponder",
|
"test": "test_trigger_transponder",
|
||||||
"code": "aabbcc",
|
"code": "aabbcc",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def test_if_fires_on_fingerprint_event(
|
async def test_if_fires_on_fingerprint_event(
|
||||||
hass: HomeAssistant, calls: list[ServiceCall], entry, lcn_connection
|
hass: HomeAssistant, service_calls: list[ServiceCall], entry, lcn_connection
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for fingerprint event triggers firing."""
|
"""Test for fingerprint event triggers firing."""
|
||||||
address = (0, 7, False)
|
address = (0, 7, False)
|
||||||
@ -158,15 +158,15 @@ async def test_if_fires_on_fingerprint_event(
|
|||||||
await lcn_connection.async_process_input(inp)
|
await lcn_connection.async_process_input(inp)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(calls) == 1
|
assert len(service_calls) == 1
|
||||||
assert calls[0].data == {
|
assert service_calls[0].data == {
|
||||||
"test": "test_trigger_fingerprint",
|
"test": "test_trigger_fingerprint",
|
||||||
"code": "aabbcc",
|
"code": "aabbcc",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def test_if_fires_on_codelock_event(
|
async def test_if_fires_on_codelock_event(
|
||||||
hass: HomeAssistant, calls: list[ServiceCall], entry, lcn_connection
|
hass: HomeAssistant, service_calls: list[ServiceCall], entry, lcn_connection
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for codelock event triggers firing."""
|
"""Test for codelock event triggers firing."""
|
||||||
address = (0, 7, False)
|
address = (0, 7, False)
|
||||||
@ -205,15 +205,15 @@ async def test_if_fires_on_codelock_event(
|
|||||||
await lcn_connection.async_process_input(inp)
|
await lcn_connection.async_process_input(inp)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(calls) == 1
|
assert len(service_calls) == 1
|
||||||
assert calls[0].data == {
|
assert service_calls[0].data == {
|
||||||
"test": "test_trigger_codelock",
|
"test": "test_trigger_codelock",
|
||||||
"code": "aabbcc",
|
"code": "aabbcc",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def test_if_fires_on_transmitter_event(
|
async def test_if_fires_on_transmitter_event(
|
||||||
hass: HomeAssistant, calls: list[ServiceCall], entry, lcn_connection
|
hass: HomeAssistant, service_calls: list[ServiceCall], entry, lcn_connection
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for transmitter event triggers firing."""
|
"""Test for transmitter event triggers firing."""
|
||||||
address = (0, 7, False)
|
address = (0, 7, False)
|
||||||
@ -258,8 +258,8 @@ async def test_if_fires_on_transmitter_event(
|
|||||||
await lcn_connection.async_process_input(inp)
|
await lcn_connection.async_process_input(inp)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(calls) == 1
|
assert len(service_calls) == 1
|
||||||
assert calls[0].data == {
|
assert service_calls[0].data == {
|
||||||
"test": "test_trigger_transmitter",
|
"test": "test_trigger_transmitter",
|
||||||
"code": "aabbcc",
|
"code": "aabbcc",
|
||||||
"level": 0,
|
"level": 0,
|
||||||
@ -269,7 +269,7 @@ async def test_if_fires_on_transmitter_event(
|
|||||||
|
|
||||||
|
|
||||||
async def test_if_fires_on_send_keys_event(
|
async def test_if_fires_on_send_keys_event(
|
||||||
hass: HomeAssistant, calls: list[ServiceCall], entry, lcn_connection
|
hass: HomeAssistant, service_calls: list[ServiceCall], entry, lcn_connection
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for send_keys event triggers firing."""
|
"""Test for send_keys event triggers firing."""
|
||||||
address = (0, 7, False)
|
address = (0, 7, False)
|
||||||
@ -309,8 +309,8 @@ async def test_if_fires_on_send_keys_event(
|
|||||||
await lcn_connection.async_process_input(inp)
|
await lcn_connection.async_process_input(inp)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(calls) == 1
|
assert len(service_calls) == 1
|
||||||
assert calls[0].data == {
|
assert service_calls[0].data == {
|
||||||
"test": "test_trigger_send_keys",
|
"test": "test_trigger_send_keys",
|
||||||
"key": "a1",
|
"key": "a1",
|
||||||
"action": "hit",
|
"action": "hit",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user