Use service_calls fixture in lutron_caseta tests (#120934)
This commit is contained in:
parent
38aa6bcf19
commit
2815c43f3e
1 changed files with 20 additions and 24 deletions
|
@ -39,11 +39,7 @@ from homeassistant.setup import async_setup_component
|
|||
|
||||
from . import MockBridge
|
||||
|
||||
from tests.common import (
|
||||
MockConfigEntry,
|
||||
async_get_device_automations,
|
||||
async_mock_service,
|
||||
)
|
||||
from tests.common import MockConfigEntry, async_get_device_automations
|
||||
|
||||
MOCK_BUTTON_DEVICES = [
|
||||
{
|
||||
|
@ -102,12 +98,6 @@ MOCK_BUTTON_DEVICES = [
|
|||
]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def calls(hass: HomeAssistant) -> list[ServiceCall]:
|
||||
"""Track calls to a mock service."""
|
||||
return async_mock_service(hass, "test", "automation")
|
||||
|
||||
|
||||
async def _async_setup_lutron_with_picos(hass):
|
||||
"""Setups a lutron bridge with picos."""
|
||||
config_entry = MockConfigEntry(
|
||||
|
@ -220,7 +210,9 @@ async def test_none_serial_keypad(
|
|||
|
||||
|
||||
async def test_if_fires_on_button_event(
|
||||
hass: HomeAssistant, calls: list[ServiceCall], device_registry: dr.DeviceRegistry
|
||||
hass: HomeAssistant,
|
||||
service_calls: list[ServiceCall],
|
||||
device_registry: dr.DeviceRegistry,
|
||||
) -> None:
|
||||
"""Test for press trigger firing."""
|
||||
await _async_setup_lutron_with_picos(hass)
|
||||
|
@ -266,12 +258,14 @@ async def test_if_fires_on_button_event(
|
|||
hass.bus.async_fire(LUTRON_CASETA_BUTTON_EVENT, message)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(calls) == 1
|
||||
assert calls[0].data["some"] == "test_trigger_button_press"
|
||||
assert len(service_calls) == 1
|
||||
assert service_calls[0].data["some"] == "test_trigger_button_press"
|
||||
|
||||
|
||||
async def test_if_fires_on_button_event_without_lip(
|
||||
hass: HomeAssistant, calls: list[ServiceCall], device_registry: dr.DeviceRegistry
|
||||
hass: HomeAssistant,
|
||||
service_calls: list[ServiceCall],
|
||||
device_registry: dr.DeviceRegistry,
|
||||
) -> None:
|
||||
"""Test for press trigger firing on a device that does not support lip."""
|
||||
await _async_setup_lutron_with_picos(hass)
|
||||
|
@ -315,12 +309,12 @@ async def test_if_fires_on_button_event_without_lip(
|
|||
hass.bus.async_fire(LUTRON_CASETA_BUTTON_EVENT, message)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(calls) == 1
|
||||
assert calls[0].data["some"] == "test_trigger_button_press"
|
||||
assert len(service_calls) == 1
|
||||
assert service_calls[0].data["some"] == "test_trigger_button_press"
|
||||
|
||||
|
||||
async def test_validate_trigger_config_no_device(
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
hass: HomeAssistant, service_calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for no press with no device."""
|
||||
|
||||
|
@ -356,11 +350,11 @@ async def test_validate_trigger_config_no_device(
|
|||
hass.bus.async_fire(LUTRON_CASETA_BUTTON_EVENT, message)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(calls) == 0
|
||||
assert len(service_calls) == 0
|
||||
|
||||
|
||||
async def test_validate_trigger_config_unknown_device(
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
hass: HomeAssistant, service_calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for no press with an unknown device."""
|
||||
|
||||
|
@ -404,7 +398,7 @@ async def test_validate_trigger_config_unknown_device(
|
|||
hass.bus.async_fire(LUTRON_CASETA_BUTTON_EVENT, message)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(calls) == 0
|
||||
assert len(service_calls) == 0
|
||||
|
||||
|
||||
async def test_validate_trigger_invalid_triggers(
|
||||
|
@ -444,7 +438,9 @@ async def test_validate_trigger_invalid_triggers(
|
|||
|
||||
|
||||
async def test_if_fires_on_button_event_late_setup(
|
||||
hass: HomeAssistant, calls: list[ServiceCall], device_registry: dr.DeviceRegistry
|
||||
hass: HomeAssistant,
|
||||
service_calls: list[ServiceCall],
|
||||
device_registry: dr.DeviceRegistry,
|
||||
) -> None:
|
||||
"""Test for press trigger firing with integration getting setup late."""
|
||||
config_entry_id = await _async_setup_lutron_with_picos(hass)
|
||||
|
@ -495,5 +491,5 @@ async def test_if_fires_on_button_event_late_setup(
|
|||
hass.bus.async_fire(LUTRON_CASETA_BUTTON_EVENT, message)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(calls) == 1
|
||||
assert calls[0].data["some"] == "test_trigger_button_press"
|
||||
assert len(service_calls) == 1
|
||||
assert service_calls[0].data["some"] == "test_trigger_button_press"
|
||||
|
|
Loading…
Add table
Reference in a new issue