Use service_calls fixture in netatmo tests (#120986)
This commit is contained in:
parent
2d054fb5df
commit
07d80d5ad9
1 changed files with 12 additions and 16 deletions
|
@ -22,16 +22,9 @@ from tests.common import (
|
|||
MockConfigEntry,
|
||||
async_capture_events,
|
||||
async_get_device_automations,
|
||||
async_mock_service,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def calls(hass: HomeAssistant) -> list[ServiceCall]:
|
||||
"""Track calls to a mock service."""
|
||||
return async_mock_service(hass, "test", "automation")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("platform", "device_type", "event_types"),
|
||||
[
|
||||
|
@ -113,7 +106,7 @@ async def test_get_triggers(
|
|||
)
|
||||
async def test_if_fires_on_event(
|
||||
hass: HomeAssistant,
|
||||
calls: list[ServiceCall],
|
||||
service_calls: list[ServiceCall],
|
||||
device_registry: dr.DeviceRegistry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
platform,
|
||||
|
@ -175,8 +168,8 @@ async def test_if_fires_on_event(
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
assert len(events) == 1
|
||||
assert len(calls) == 1
|
||||
assert calls[0].data["some"] == f"{event_type} - device - {device.id}"
|
||||
assert len(service_calls) == 1
|
||||
assert service_calls[0].data["some"] == f"{event_type} - device - {device.id}"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@ -196,7 +189,7 @@ async def test_if_fires_on_event(
|
|||
)
|
||||
async def test_if_fires_on_event_legacy(
|
||||
hass: HomeAssistant,
|
||||
calls: list[ServiceCall],
|
||||
service_calls: list[ServiceCall],
|
||||
device_registry: dr.DeviceRegistry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
platform,
|
||||
|
@ -258,8 +251,8 @@ async def test_if_fires_on_event_legacy(
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
assert len(events) == 1
|
||||
assert len(calls) == 1
|
||||
assert calls[0].data["some"] == f"{event_type} - device - {device.id}"
|
||||
assert len(service_calls) == 1
|
||||
assert service_calls[0].data["some"] == f"{event_type} - device - {device.id}"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@ -275,7 +268,7 @@ async def test_if_fires_on_event_legacy(
|
|||
)
|
||||
async def test_if_fires_on_event_with_subtype(
|
||||
hass: HomeAssistant,
|
||||
calls: list[ServiceCall],
|
||||
service_calls: list[ServiceCall],
|
||||
device_registry: dr.DeviceRegistry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
platform,
|
||||
|
@ -343,8 +336,11 @@ async def test_if_fires_on_event_with_subtype(
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
assert len(events) == 1
|
||||
assert len(calls) == 1
|
||||
assert calls[0].data["some"] == f"{event_type} - {sub_type} - device - {device.id}"
|
||||
assert len(service_calls) == 1
|
||||
assert (
|
||||
service_calls[0].data["some"]
|
||||
== f"{event_type} - {sub_type} - device - {device.id}"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
|
Loading…
Add table
Reference in a new issue