Use service_calls fixture in hue tests (#120928)

pull/120255/head
epenet 2024-07-01 16:16:19 +02:00 committed by GitHub
parent bc3562a9e8
commit c9911fa8ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 17 deletions

View File

@ -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.v2.device import async_setup_devices
from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.setup import async_setup_component
from .const import FAKE_BRIDGE, FAKE_BRIDGE_DEVICE
from tests.common import (
MockConfigEntry,
async_mock_service,
load_fixture,
mock_device_registry,
)
from tests.common import MockConfigEntry, load_fixture, mock_device_registry
@pytest.fixture(autouse=True)
@ -288,9 +282,3 @@ async def setup_platform(
def get_device_reg(hass):
"""Return an empty, loaded, registry."""
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")

View File

@ -92,7 +92,7 @@ async def test_if_fires_on_state_change(
hass: HomeAssistant,
mock_bridge_v1,
device_reg: dr.DeviceRegistry,
calls: list[ServiceCall],
service_calls: list[ServiceCall],
) -> None:
"""Test for button press trigger firing."""
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(calls) == 1
assert calls[0].data["some"] == "B4 - 18"
assert len(service_calls) == 1
assert service_calls[0].data["some"] == "B4 - 18"
# Fake another button press.
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 hass.async_block_till_done()
assert len(mock_bridge_v1.mock_requests) == 3
assert len(calls) == 1
assert len(service_calls) == 1