From 0c38aa56f5d0723f73602d3ddb4049f8b6f924dd Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 29 May 2024 09:26:44 +0200 Subject: [PATCH] Rename calls fixture in components tests (#118355) --- tests/components/demo/test_notify.py | 20 +------------------ .../google_mail/test_config_flow.py | 6 +++--- tests/components/hdmi_cec/test_init.py | 13 ++++++++---- tests/components/youtube/test_config_flow.py | 6 +++--- 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/tests/components/demo/test_notify.py b/tests/components/demo/test_notify.py index 50730fb6c1e..9b8d4aac0b2 100644 --- a/tests/components/demo/test_notify.py +++ b/tests/components/demo/test_notify.py @@ -9,7 +9,7 @@ from homeassistant.components import notify from homeassistant.components.demo import DOMAIN import homeassistant.components.demo.notify as demo from homeassistant.const import Platform -from homeassistant.core import Event, HomeAssistant, callback +from homeassistant.core import Event, HomeAssistant from homeassistant.setup import async_setup_component from tests.common import MockConfigEntry, async_capture_events @@ -42,24 +42,6 @@ def events(hass: HomeAssistant) -> list[Event]: return async_capture_events(hass, demo.EVENT_NOTIFY) -@pytest.fixture -def calls(): - """Fixture to calls.""" - return [] - - -@pytest.fixture -def record_calls(calls): - """Fixture to record calls.""" - - @callback - def record_calls(*args): - """Record calls.""" - calls.append(args) - - return record_calls - - async def test_sending_message(hass: HomeAssistant, events: list[Event]) -> None: """Test sending a message.""" data = { diff --git a/tests/components/google_mail/test_config_flow.py b/tests/components/google_mail/test_config_flow.py index 06479504f9d..d39e1081635 100644 --- a/tests/components/google_mail/test_config_flow.py +++ b/tests/components/google_mail/test_config_flow.py @@ -76,7 +76,7 @@ async def test_full_flow( @pytest.mark.parametrize( - ("fixture", "abort_reason", "placeholders", "calls", "access_token"), + ("fixture", "abort_reason", "placeholders", "call_count", "access_token"), [ ("get_profile", "reauth_successful", None, 1, "updated-access-token"), ( @@ -97,7 +97,7 @@ async def test_reauth( fixture: str, abort_reason: str, placeholders: dict[str, str], - calls: int, + call_count: int, access_token: str, ) -> None: """Test the re-authentication case updates the correct config entry. @@ -164,7 +164,7 @@ async def test_reauth( assert result.get("type") is FlowResultType.ABORT assert result["reason"] == abort_reason assert result["description_placeholders"] == placeholders - assert len(mock_setup.mock_calls) == calls + assert len(mock_setup.mock_calls) == call_count assert config_entry.unique_id == TITLE assert "token" in config_entry.data diff --git a/tests/components/hdmi_cec/test_init.py b/tests/components/hdmi_cec/test_init.py index b8cbf1ea8cd..1263078c196 100644 --- a/tests/components/hdmi_cec/test_init.py +++ b/tests/components/hdmi_cec/test_init.py @@ -277,7 +277,7 @@ async def test_service_update_devices(hass: HomeAssistant, create_hdmi_network) @pytest.mark.parametrize( - ("count", "calls"), + ("count", "call_count"), [ (3, 3), (1, 1), @@ -294,7 +294,12 @@ async def test_service_update_devices(hass: HomeAssistant, create_hdmi_network) ) @pytest.mark.parametrize(("direction", "key"), [("up", 65), ("down", 66)]) async def test_service_volume_x_times( - hass: HomeAssistant, create_hdmi_network, count, calls, direction, key + hass: HomeAssistant, + create_hdmi_network, + count: int, + call_count: int, + direction, + key, ) -> None: """Test the volume service call with steps.""" mock_hdmi_network_instance = await create_hdmi_network() @@ -306,8 +311,8 @@ async def test_service_volume_x_times( blocking=True, ) - assert mock_hdmi_network_instance.send_command.call_count == calls * 2 - for i in range(calls): + assert mock_hdmi_network_instance.send_command.call_count == call_count * 2 + for i in range(call_count): assert_key_press_release( mock_hdmi_network_instance.send_command, i, dst=5, key=key ) diff --git a/tests/components/youtube/test_config_flow.py b/tests/components/youtube/test_config_flow.py index 95a56155980..91826e93406 100644 --- a/tests/components/youtube/test_config_flow.py +++ b/tests/components/youtube/test_config_flow.py @@ -211,7 +211,7 @@ async def test_flow_http_error( @pytest.mark.parametrize( - ("fixture", "abort_reason", "placeholders", "calls", "access_token"), + ("fixture", "abort_reason", "placeholders", "call_count", "access_token"), [ ( "get_channel", @@ -238,7 +238,7 @@ async def test_reauth( fixture: str, abort_reason: str, placeholders: dict[str, str], - calls: int, + call_count: int, access_token: str, ) -> None: """Test the re-authentication case updates the correct config entry. @@ -303,7 +303,7 @@ async def test_reauth( assert result["type"] is FlowResultType.ABORT assert result["reason"] == abort_reason assert result["description_placeholders"] == placeholders - assert len(mock_setup.mock_calls) == calls + assert len(mock_setup.mock_calls) == call_count assert config_entry.unique_id == "UC_x5XG1OV2P6uZZ5FSM9Ttw" assert "token" in config_entry.data