mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Use service_calls fixture in hue tests (#120928)
This commit is contained in:
parent
bc3562a9e8
commit
c9911fa8ce
@ -16,17 +16,11 @@ from homeassistant.components import hue
|
|||||||
from homeassistant.components.hue.v1 import sensor_base as hue_sensor_base
|
from homeassistant.components.hue.v1 import sensor_base as hue_sensor_base
|
||||||
from homeassistant.components.hue.v2.device import async_setup_devices
|
from homeassistant.components.hue.v2.device import async_setup_devices
|
||||||
from homeassistant.config_entries import ConfigEntryState
|
from homeassistant.config_entries import ConfigEntryState
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall
|
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from .const import FAKE_BRIDGE, FAKE_BRIDGE_DEVICE
|
from .const import FAKE_BRIDGE, FAKE_BRIDGE_DEVICE
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import MockConfigEntry, load_fixture, mock_device_registry
|
||||||
MockConfigEntry,
|
|
||||||
async_mock_service,
|
|
||||||
load_fixture,
|
|
||||||
mock_device_registry,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
@ -288,9 +282,3 @@ async def setup_platform(
|
|||||||
def get_device_reg(hass):
|
def get_device_reg(hass):
|
||||||
"""Return an empty, loaded, registry."""
|
"""Return an empty, loaded, registry."""
|
||||||
return mock_device_registry(hass)
|
return mock_device_registry(hass)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="calls")
|
|
||||||
def track_calls(hass: HomeAssistant) -> list[ServiceCall]:
|
|
||||||
"""Track calls to a mock service."""
|
|
||||||
return async_mock_service(hass, "test", "automation")
|
|
||||||
|
@ -92,7 +92,7 @@ async def test_if_fires_on_state_change(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_bridge_v1,
|
mock_bridge_v1,
|
||||||
device_reg: dr.DeviceRegistry,
|
device_reg: dr.DeviceRegistry,
|
||||||
calls: list[ServiceCall],
|
service_calls: list[ServiceCall],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for button press trigger firing."""
|
"""Test for button press trigger firing."""
|
||||||
mock_bridge_v1.mock_sensor_responses.append(REMOTES_RESPONSE)
|
mock_bridge_v1.mock_sensor_responses.append(REMOTES_RESPONSE)
|
||||||
@ -158,8 +158,8 @@ async def test_if_fires_on_state_change(
|
|||||||
|
|
||||||
assert len(mock_bridge_v1.mock_requests) == 2
|
assert len(mock_bridge_v1.mock_requests) == 2
|
||||||
|
|
||||||
assert len(calls) == 1
|
assert len(service_calls) == 1
|
||||||
assert calls[0].data["some"] == "B4 - 18"
|
assert service_calls[0].data["some"] == "B4 - 18"
|
||||||
|
|
||||||
# Fake another button press.
|
# Fake another button press.
|
||||||
new_sensor_response["7"] = dict(new_sensor_response["7"])
|
new_sensor_response["7"] = dict(new_sensor_response["7"])
|
||||||
@ -173,4 +173,4 @@ async def test_if_fires_on_state_change(
|
|||||||
await mock_bridge_v1.sensor_manager.coordinator.async_refresh()
|
await mock_bridge_v1.sensor_manager.coordinator.async_refresh()
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert len(mock_bridge_v1.mock_requests) == 3
|
assert len(mock_bridge_v1.mock_requests) == 3
|
||||||
assert len(calls) == 1
|
assert len(service_calls) == 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user