mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +00:00
Use service_calls fixture in netatmo tests (#120986)
This commit is contained in:
parent
2d054fb5df
commit
07d80d5ad9
@ -22,16 +22,9 @@ from tests.common import (
|
|||||||
MockConfigEntry,
|
MockConfigEntry,
|
||||||
async_capture_events,
|
async_capture_events,
|
||||||
async_get_device_automations,
|
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(
|
@pytest.mark.parametrize(
|
||||||
("platform", "device_type", "event_types"),
|
("platform", "device_type", "event_types"),
|
||||||
[
|
[
|
||||||
@ -113,7 +106,7 @@ async def test_get_triggers(
|
|||||||
)
|
)
|
||||||
async def test_if_fires_on_event(
|
async def test_if_fires_on_event(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
calls: list[ServiceCall],
|
service_calls: list[ServiceCall],
|
||||||
device_registry: dr.DeviceRegistry,
|
device_registry: dr.DeviceRegistry,
|
||||||
entity_registry: er.EntityRegistry,
|
entity_registry: er.EntityRegistry,
|
||||||
platform,
|
platform,
|
||||||
@ -175,8 +168,8 @@ async def test_if_fires_on_event(
|
|||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert len(events) == 1
|
assert len(events) == 1
|
||||||
assert len(calls) == 1
|
assert len(service_calls) == 1
|
||||||
assert calls[0].data["some"] == f"{event_type} - device - {device.id}"
|
assert service_calls[0].data["some"] == f"{event_type} - device - {device.id}"
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
@ -196,7 +189,7 @@ async def test_if_fires_on_event(
|
|||||||
)
|
)
|
||||||
async def test_if_fires_on_event_legacy(
|
async def test_if_fires_on_event_legacy(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
calls: list[ServiceCall],
|
service_calls: list[ServiceCall],
|
||||||
device_registry: dr.DeviceRegistry,
|
device_registry: dr.DeviceRegistry,
|
||||||
entity_registry: er.EntityRegistry,
|
entity_registry: er.EntityRegistry,
|
||||||
platform,
|
platform,
|
||||||
@ -258,8 +251,8 @@ async def test_if_fires_on_event_legacy(
|
|||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert len(events) == 1
|
assert len(events) == 1
|
||||||
assert len(calls) == 1
|
assert len(service_calls) == 1
|
||||||
assert calls[0].data["some"] == f"{event_type} - device - {device.id}"
|
assert service_calls[0].data["some"] == f"{event_type} - device - {device.id}"
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
@ -275,7 +268,7 @@ async def test_if_fires_on_event_legacy(
|
|||||||
)
|
)
|
||||||
async def test_if_fires_on_event_with_subtype(
|
async def test_if_fires_on_event_with_subtype(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
calls: list[ServiceCall],
|
service_calls: list[ServiceCall],
|
||||||
device_registry: dr.DeviceRegistry,
|
device_registry: dr.DeviceRegistry,
|
||||||
entity_registry: er.EntityRegistry,
|
entity_registry: er.EntityRegistry,
|
||||||
platform,
|
platform,
|
||||||
@ -343,8 +336,11 @@ async def test_if_fires_on_event_with_subtype(
|
|||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert len(events) == 1
|
assert len(events) == 1
|
||||||
assert len(calls) == 1
|
assert len(service_calls) == 1
|
||||||
assert calls[0].data["some"] == f"{event_type} - {sub_type} - device - {device.id}"
|
assert (
|
||||||
|
service_calls[0].data["some"]
|
||||||
|
== f"{event_type} - {sub_type} - device - {device.id}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user