diff --git a/tests/components/motionblinds_ble/conftest.py b/tests/components/motionblinds_ble/conftest.py index ae487957302..342e958eae4 100644 --- a/tests/components/motionblinds_ble/conftest.py +++ b/tests/components/motionblinds_ble/conftest.py @@ -3,6 +3,7 @@ from unittest.mock import AsyncMock, Mock, patch import pytest +from typing_extensions import Generator TEST_MAC = "abcd" TEST_NAME = f"MOTION_{TEST_MAC.upper()}" @@ -10,7 +11,9 @@ TEST_ADDRESS = "test_adress" @pytest.fixture(name="motionblinds_ble_connect", autouse=True) -def motion_blinds_connect_fixture(enable_bluetooth): +def motion_blinds_connect_fixture( + enable_bluetooth: None, +) -> Generator[tuple[AsyncMock, Mock]]: """Mock motion blinds ble connection and entry setup.""" device = Mock() device.name = TEST_NAME diff --git a/tests/components/motionblinds_ble/test_config_flow.py b/tests/components/motionblinds_ble/test_config_flow.py index f5a988a628d..90d2cbdcbc6 100644 --- a/tests/components/motionblinds_ble/test_config_flow.py +++ b/tests/components/motionblinds_ble/test_config_flow.py @@ -1,8 +1,9 @@ """Test the Motionblinds Bluetooth config flow.""" -from unittest.mock import patch +from unittest.mock import AsyncMock, Mock, patch from motionblindsble.const import MotionBlindType +import pytest from homeassistant import config_entries from homeassistant.components.bluetooth.models import BluetoothServiceInfoBleak @@ -43,9 +44,8 @@ BLIND_SERVICE_INFO = BluetoothServiceInfoBleak( ) -async def test_config_flow_manual_success( - hass: HomeAssistant, motionblinds_ble_connect -) -> None: +@pytest.mark.usefixtures("motionblinds_ble_connect") +async def test_config_flow_manual_success(hass: HomeAssistant) -> None: """Successful flow manually initialized by the user.""" result = await hass.config_entries.flow.async_init( const.DOMAIN, context={"source": config_entries.SOURCE_USER} @@ -76,9 +76,8 @@ async def test_config_flow_manual_success( assert result["options"] == {} -async def test_config_flow_manual_error_invalid_mac( - hass: HomeAssistant, motionblinds_ble_connect -) -> None: +@pytest.mark.usefixtures("motionblinds_ble_connect") +async def test_config_flow_manual_error_invalid_mac(hass: HomeAssistant) -> None: """Invalid MAC code error flow manually initialized by the user.""" # Initialize @@ -122,8 +121,9 @@ async def test_config_flow_manual_error_invalid_mac( assert result["options"] == {} +@pytest.mark.usefixtures("motionblinds_ble_connect") async def test_config_flow_manual_error_no_bluetooth_adapter( - hass: HomeAssistant, motionblinds_ble_connect + hass: HomeAssistant, ) -> None: """No Bluetooth adapter error flow manually initialized by the user.""" @@ -159,7 +159,7 @@ async def test_config_flow_manual_error_no_bluetooth_adapter( async def test_config_flow_manual_error_could_not_find_motor( - hass: HomeAssistant, motionblinds_ble_connect + hass: HomeAssistant, motionblinds_ble_connect: tuple[AsyncMock, Mock] ) -> None: """Could not find motor error flow manually initialized by the user.""" @@ -207,7 +207,7 @@ async def test_config_flow_manual_error_could_not_find_motor( async def test_config_flow_manual_error_no_devices_found( - hass: HomeAssistant, motionblinds_ble_connect + hass: HomeAssistant, motionblinds_ble_connect: tuple[AsyncMock, Mock] ) -> None: """No devices found error flow manually initialized by the user.""" @@ -229,9 +229,8 @@ async def test_config_flow_manual_error_no_devices_found( assert result["reason"] == const.ERROR_NO_DEVICES_FOUND -async def test_config_flow_bluetooth_success( - hass: HomeAssistant, motionblinds_ble_connect -) -> None: +@pytest.mark.usefixtures("motionblinds_ble_connect") +async def test_config_flow_bluetooth_success(hass: HomeAssistant) -> None: """Successful bluetooth discovery flow.""" result = await hass.config_entries.flow.async_init( const.DOMAIN,