From fb5116307561d1921a447347804ab383702fae63 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 6 Jun 2024 17:27:38 +0200 Subject: [PATCH] Move socket_enabled fixture to decorator (#118847) --- tests/components/esphome/test_voice_assistant.py | 9 +++------ tests/components/google/test_diagnostics.py | 2 +- tests/components/hassio/test_handler.py | 2 +- tests/components/local_calendar/test_diagnostics.py | 4 ++-- tests/components/utility_meter/test_diagnostics.py | 3 ++- tests/components/voip/test_sip.py | 3 ++- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/tests/components/esphome/test_voice_assistant.py b/tests/components/esphome/test_voice_assistant.py index 305d0e395a3..701ce76a207 100644 --- a/tests/components/esphome/test_voice_assistant.py +++ b/tests/components/esphome/test_voice_assistant.py @@ -186,9 +186,8 @@ async def test_pipeline_events( ) +@pytest.mark.usefixtures("socket_enabled") async def test_udp_server( - hass: HomeAssistant, - socket_enabled: None, unused_udp_port_factory: Callable[[], int], voice_assistant_udp_pipeline_v1: VoiceAssistantUDPPipeline, ) -> None: @@ -313,9 +312,8 @@ async def test_error_calls_handle_finished( voice_assistant_udp_pipeline_v1.handle_finished.assert_called() +@pytest.mark.usefixtures("socket_enabled") async def test_udp_server_multiple( - hass: HomeAssistant, - socket_enabled: None, unused_udp_port_factory: Callable[[], int], voice_assistant_udp_pipeline_v1: VoiceAssistantUDPPipeline, ) -> None: @@ -336,9 +334,8 @@ async def test_udp_server_multiple( await voice_assistant_udp_pipeline_v1.start_server() +@pytest.mark.usefixtures("socket_enabled") async def test_udp_server_after_stopped( - hass: HomeAssistant, - socket_enabled: None, unused_udp_port_factory: Callable[[], int], voice_assistant_udp_pipeline_v1: VoiceAssistantUDPPipeline, ) -> None: diff --git a/tests/components/google/test_diagnostics.py b/tests/components/google/test_diagnostics.py index 69a1929b5ed..5d6259309b8 100644 --- a/tests/components/google/test_diagnostics.py +++ b/tests/components/google/test_diagnostics.py @@ -62,6 +62,7 @@ async def setup_diag(hass): @freeze_time("2023-03-13 12:05:00-07:00") +@pytest.mark.usefixtures("socket_enabled") async def test_diagnostics( hass: HomeAssistant, component_setup: ComponentSetup, @@ -70,7 +71,6 @@ async def test_diagnostics( hass_admin_credential: Credentials, config_entry: MockConfigEntry, aiohttp_client: ClientSessionGenerator, - socket_enabled: None, snapshot: SnapshotAssertion, aioclient_mock: AiohttpClientMocker, ) -> None: diff --git a/tests/components/hassio/test_handler.py b/tests/components/hassio/test_handler.py index 5089613285d..c418576a802 100644 --- a/tests/components/hassio/test_handler.py +++ b/tests/components/hassio/test_handler.py @@ -320,10 +320,10 @@ async def test_api_ingress_panels( ("update_diagnostics", "POST", True), ], ) +@pytest.mark.usefixtures("socket_enabled") async def test_api_headers( aiohttp_raw_server, # 'aiohttp_raw_server' must be before 'hass'! hass: HomeAssistant, - socket_enabled: None, api_call: str, method: Literal["GET", "POST"], payload: Any, diff --git a/tests/components/local_calendar/test_diagnostics.py b/tests/components/local_calendar/test_diagnostics.py index 721eed19736..ed12391f8a9 100644 --- a/tests/components/local_calendar/test_diagnostics.py +++ b/tests/components/local_calendar/test_diagnostics.py @@ -48,6 +48,7 @@ async def setup_diag(hass): @freeze_time("2023-03-13 12:05:00-07:00") +@pytest.mark.usefixtures("socket_enabled") async def test_empty_calendar( hass: HomeAssistant, setup_integration: None, @@ -55,7 +56,6 @@ async def test_empty_calendar( hass_admin_credential: Credentials, config_entry: MockConfigEntry, aiohttp_client: ClientSessionGenerator, - socket_enabled: None, snapshot: SnapshotAssertion, ) -> None: """Test diagnostics against an empty calendar.""" @@ -76,6 +76,7 @@ async def test_empty_calendar( @freeze_time("2023-03-13 12:05:00-07:00") +@pytest.mark.usefixtures("socket_enabled") async def test_api_date_time_event( hass: HomeAssistant, setup_integration: None, @@ -84,7 +85,6 @@ async def test_api_date_time_event( config_entry: MockConfigEntry, hass_ws_client: WebSocketGenerator, aiohttp_client: ClientSessionGenerator, - socket_enabled: None, snapshot: SnapshotAssertion, ) -> None: """Test an event with a start/end date time.""" diff --git a/tests/components/utility_meter/test_diagnostics.py b/tests/components/utility_meter/test_diagnostics.py index 083fd965e90..cefd17fc7e4 100644 --- a/tests/components/utility_meter/test_diagnostics.py +++ b/tests/components/utility_meter/test_diagnostics.py @@ -2,6 +2,7 @@ from aiohttp.test_utils import TestClient from freezegun import freeze_time +import pytest from syrupy import SnapshotAssertion from homeassistant.auth.models import Credentials @@ -50,12 +51,12 @@ def limit_diagnostic_attrs(prop, path) -> bool: @freeze_time("2024-04-06 00:00:00+00:00") +@pytest.mark.usefixtures("socket_enabled") async def test_diagnostics( hass: HomeAssistant, aiohttp_client: ClientSessionGenerator, hass_admin_user: MockUser, hass_admin_credential: Credentials, - socket_enabled: None, snapshot: SnapshotAssertion, ) -> None: """Test generating diagnostics for a config entry.""" diff --git a/tests/components/voip/test_sip.py b/tests/components/voip/test_sip.py index 1ca2f4aaaf2..8c070df7247 100644 --- a/tests/components/voip/test_sip.py +++ b/tests/components/voip/test_sip.py @@ -9,7 +9,8 @@ from homeassistant.components import voip from homeassistant.core import HomeAssistant -async def test_create_sip_server(hass: HomeAssistant, socket_enabled: None) -> None: +@pytest.mark.usefixtures("socket_enabled") +async def test_create_sip_server(hass: HomeAssistant) -> None: """Tests starting/stopping SIP server.""" result = await hass.config_entries.flow.async_init( voip.DOMAIN, context={"source": config_entries.SOURCE_USER}