From 51d5e21203b1a3e591c254a56815bf5c92829c45 Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Fri, 26 Jul 2024 09:48:12 +0200 Subject: [PATCH] Remove unused fixtures in UniFi tests (#122628) --- tests/components/unifi/conftest.py | 2 +- tests/components/unifi/test_config_flow.py | 15 +++++---------- tests/components/unifi/test_init.py | 5 +---- tests/components/unifi/test_services.py | 2 +- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/tests/components/unifi/conftest.py b/tests/components/unifi/conftest.py index f1ebe84c350..c20b8766bfc 100644 --- a/tests/components/unifi/conftest.py +++ b/tests/components/unifi/conftest.py @@ -295,7 +295,7 @@ async def fixture_config_entry_factory( @pytest.fixture(name="config_entry_setup") async def fixture_config_entry_setup( - hass: HomeAssistant, config_entry_factory: Callable[[], ConfigEntry] + config_entry_factory: Callable[[], ConfigEntry], ) -> ConfigEntry: """Fixture providing a set up instance of UniFi network integration.""" return await config_entry_factory() diff --git a/tests/components/unifi/test_config_flow.py b/tests/components/unifi/test_config_flow.py index 9ae3af19b46..fc0d2626eb6 100644 --- a/tests/components/unifi/test_config_flow.py +++ b/tests/components/unifi/test_config_flow.py @@ -37,7 +37,6 @@ from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType from tests.common import MockConfigEntry -from tests.test_util.aiohttp import AiohttpClientMocker CLIENTS = [{"mac": "00:00:00:00:00:01"}] @@ -137,9 +136,7 @@ async def test_flow_works(hass: HomeAssistant, mock_discovery) -> None: } -async def test_flow_works_negative_discovery( - hass: HomeAssistant, aioclient_mock: AiohttpClientMocker -) -> None: +async def test_flow_works_negative_discovery(hass: HomeAssistant) -> None: """Test config flow with a negative outcome of async_discovery_unifi.""" result = await hass.config_entries.flow.async_init( UNIFI_DOMAIN, context={"source": config_entries.SOURCE_USER} @@ -535,9 +532,8 @@ async def test_form_ssdp(hass: HomeAssistant) -> None: } -async def test_form_ssdp_aborts_if_host_already_exists( - hass: HomeAssistant, config_entry: ConfigEntry -) -> None: +@pytest.mark.usefixtures("config_entry") +async def test_form_ssdp_aborts_if_host_already_exists(hass: HomeAssistant) -> None: """Test we abort if the host is already configured.""" result = await hass.config_entries.flow.async_init( UNIFI_DOMAIN, @@ -557,9 +553,8 @@ async def test_form_ssdp_aborts_if_host_already_exists( assert result["reason"] == "already_configured" -async def test_form_ssdp_aborts_if_serial_already_exists( - hass: HomeAssistant, config_entry: ConfigEntry -) -> None: +@pytest.mark.usefixtures("config_entry") +async def test_form_ssdp_aborts_if_serial_already_exists(hass: HomeAssistant) -> None: """Test we abort if the serial is already configured.""" result = await hass.config_entries.flow.async_init( diff --git a/tests/components/unifi/test_init.py b/tests/components/unifi/test_init.py index 7cd203ab8fd..fe464989af3 100644 --- a/tests/components/unifi/test_init.py +++ b/tests/components/unifi/test_init.py @@ -24,7 +24,6 @@ from homeassistant.setup import async_setup_component from .conftest import DEFAULT_CONFIG_ENTRY_ID from tests.common import flush_store -from tests.test_util.aiohttp import AiohttpClientMocker from tests.typing import WebSocketGenerator @@ -35,7 +34,7 @@ async def test_setup_with_no_config(hass: HomeAssistant) -> None: async def test_setup_entry_fails_config_entry_not_ready( - hass: HomeAssistant, config_entry_factory: Callable[[], ConfigEntry] + config_entry_factory: Callable[[], ConfigEntry], ) -> None: """Failed authentication trigger a reauthentication flow.""" with patch( @@ -170,8 +169,6 @@ async def test_wireless_clients( ) async def test_remove_config_entry_device( hass: HomeAssistant, - hass_storage: dict[str, Any], - aioclient_mock: AiohttpClientMocker, device_registry: dr.DeviceRegistry, config_entry_factory: Callable[[], ConfigEntry], client_payload: list[dict[str, Any]], diff --git a/tests/components/unifi/test_services.py b/tests/components/unifi/test_services.py index e3b03bc868d..bf7058e28ff 100644 --- a/tests/components/unifi/test_services.py +++ b/tests/components/unifi/test_services.py @@ -289,7 +289,7 @@ async def test_services_handle_unloaded_config_entry( aioclient_mock: AiohttpClientMocker, device_registry: dr.DeviceRegistry, config_entry_setup: ConfigEntry, - clients_all_payload, + clients_all_payload: dict[str, Any], ) -> None: """Verify no call is made if config entry is unloaded.""" await hass.config_entries.async_unload(config_entry_setup.entry_id)