mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Use service_calls fixture in kodi tests (#120929)
This commit is contained in:
parent
c6cfe073ea
commit
b3a50893cf
@ -12,11 +12,7 @@ from homeassistant.setup import async_setup_component
|
||||
|
||||
from . import init_integration
|
||||
|
||||
from tests.common import (
|
||||
MockConfigEntry,
|
||||
async_get_device_automations,
|
||||
async_mock_service,
|
||||
)
|
||||
from tests.common import MockConfigEntry, async_get_device_automations
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True, name="stub_blueprint_populate")
|
||||
@ -24,12 +20,6 @@ def stub_blueprint_populate_autouse(stub_blueprint_populate: None) -> None:
|
||||
"""Stub copying the blueprints to the config folder."""
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def calls(hass: HomeAssistant) -> list[ServiceCall]:
|
||||
"""Track calls to a mock service."""
|
||||
return async_mock_service(hass, "test", "automation")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def kodi_media_player(hass):
|
||||
"""Get a kodi media player."""
|
||||
@ -77,7 +67,7 @@ async def test_get_triggers(
|
||||
async def test_if_fires_on_state_change(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
calls: list[ServiceCall],
|
||||
service_calls: list[ServiceCall],
|
||||
kodi_media_player,
|
||||
) -> None:
|
||||
"""Test for turn_on and turn_off triggers firing."""
|
||||
@ -135,8 +125,8 @@ async def test_if_fires_on_state_change(
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
assert calls[0].data["some"] == f"turn_on - {kodi_media_player} - 0"
|
||||
assert len(service_calls) == 2
|
||||
assert service_calls[1].data["some"] == f"turn_on - {kodi_media_player} - 0"
|
||||
|
||||
await hass.services.async_call(
|
||||
MP_DOMAIN,
|
||||
@ -146,14 +136,14 @@ async def test_if_fires_on_state_change(
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 2
|
||||
assert calls[1].data["some"] == f"turn_off - {kodi_media_player} - 0"
|
||||
assert len(service_calls) == 4
|
||||
assert service_calls[3].data["some"] == f"turn_off - {kodi_media_player} - 0"
|
||||
|
||||
|
||||
async def test_if_fires_on_state_change_legacy(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
calls: list[ServiceCall],
|
||||
service_calls: list[ServiceCall],
|
||||
kodi_media_player,
|
||||
) -> None:
|
||||
"""Test for turn_on and turn_off triggers firing."""
|
||||
@ -194,5 +184,5 @@ async def test_if_fires_on_state_change_legacy(
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
assert calls[0].data["some"] == f"turn_on - {kodi_media_player} - 0"
|
||||
assert len(service_calls) == 2
|
||||
assert service_calls[1].data["some"] == f"turn_on - {kodi_media_player} - 0"
|
||||
|
Loading…
x
Reference in New Issue
Block a user