From b3a50893cfa77a531142fb247a2c59a52b9f5038 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:55:01 +0200 Subject: [PATCH] Use service_calls fixture in kodi tests (#120929) --- tests/components/kodi/test_device_trigger.py | 28 +++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/tests/components/kodi/test_device_trigger.py b/tests/components/kodi/test_device_trigger.py index d3de349018e..587aab76931 100644 --- a/tests/components/kodi/test_device_trigger.py +++ b/tests/components/kodi/test_device_trigger.py @@ -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"