Use service_calls fixture in bthome tests (#119268)
parent
a5cde4b32b
commit
42f3dd636f
|
@ -1,7 +1,5 @@
|
|||
"""Test BTHome BLE events."""
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components import automation
|
||||
from homeassistant.components.bluetooth.const import DOMAIN as BLUETOOTH_DOMAIN
|
||||
from homeassistant.components.bthome.const import CONF_SUBTYPE, DOMAIN
|
||||
|
@ -20,7 +18,6 @@ from tests.common import (
|
|||
MockConfigEntry,
|
||||
async_capture_events,
|
||||
async_get_device_automations,
|
||||
async_mock_service,
|
||||
)
|
||||
from tests.components.bluetooth import inject_bluetooth_service_info_bleak
|
||||
|
||||
|
@ -31,12 +28,6 @@ def get_device_id(mac: str) -> tuple[str, str]:
|
|||
return (BLUETOOTH_DOMAIN, mac)
|
||||
|
||||
|
||||
@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_bthome_device(hass, mac: str):
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -230,7 +221,7 @@ async def test_get_triggers_for_invalid_device_id(hass: HomeAssistant) -> None:
|
|||
|
||||
|
||||
async def test_if_fires_on_motion_detected(
|
||||
hass: HomeAssistant, calls: list[ServiceCall]
|
||||
hass: HomeAssistant, service_calls: list[ServiceCall]
|
||||
) -> None:
|
||||
"""Test for motion event trigger firing."""
|
||||
mac = "DE:70:E8:B2:39:0C"
|
||||
|
@ -278,8 +269,8 @@ async def test_if_fires_on_motion_detected(
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(calls) == 1
|
||||
assert calls[0].data["some"] == "test_trigger_button_long_press"
|
||||
assert len(service_calls) == 1
|
||||
assert service_calls[0].data["some"] == "test_trigger_button_long_press"
|
||||
|
||||
assert await hass.config_entries.async_unload(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
|
Loading…
Reference in New Issue