diff --git a/tests/components/hue_ble/__init__.py b/tests/components/hue_ble/__init__.py index c12c1185117fd..a80a28df5388a 100644 --- a/tests/components/hue_ble/__init__.py +++ b/tests/components/hue_ble/__init__.py @@ -1 +1,44 @@ """Tests for the HueBLE Bluetooth integration.""" + +from habluetooth import BluetoothServiceInfoBleak + +from tests.components.bluetooth import generate_advertisement_data, generate_ble_device + +TEST_DEVICE_NAME = "Hue Light" +TEST_DEVICE_MAC = "AA:BB:CC:DD:EE:FF" + +HUE_BLE_SERVICE_INFO = BluetoothServiceInfoBleak( + name=TEST_DEVICE_NAME, + manufacturer_data={89: b"\x12\x02\x00\x02"}, + service_data={"0000fe0f-0000-1000-8000-00805f9b34fb": b"\x02\x10\x0e\xbe\x00"}, + service_uuids=[ + "00001800-0000-1000-8000-00805f9b34fb", + "00001801-0000-1000-8000-00805f9b34fb", + "0000180a-0000-1000-8000-00805f9b34fb", + "0000fe0f-0000-1000-8000-00805f9b34fb", + "932c32bd-0000-47a2-835a-a8d455b859dd", + "9da2ddf1-0000-44d0-909c-3f3d3cb34a7b", + "b8843add-0000-4aa1-8794-c3f462030bda", + ], + address=TEST_DEVICE_MAC, + rssi=-60, + source="local", + advertisement=generate_advertisement_data( + local_name=TEST_DEVICE_NAME, + manufacturer_data={89: b"\xfd`0U\x92W"}, + service_data={"0000fe0f-0000-1000-8000-00805f9b34fb": b"\x02\x10\x0e\xbe\x00"}, + service_uuids=[ + "00001800-0000-1000-8000-00805f9b34fb", + "00001801-0000-1000-8000-00805f9b34fb", + "0000180a-0000-1000-8000-00805f9b34fb", + "0000fe0f-0000-1000-8000-00805f9b34fb", + "932c32bd-0000-47a2-835a-a8d455b859dd", + "9da2ddf1-0000-44d0-909c-3f3d3cb34a7b", + "b8843add-0000-4aa1-8794-c3f462030bda", + ], + ), + device=generate_ble_device(TEST_DEVICE_MAC, TEST_DEVICE_NAME), + time=0, + connectable=True, + tx_power=-127, +) diff --git a/tests/components/hue_ble/test_config_flow.py b/tests/components/hue_ble/test_config_flow.py index 5f39ce91ffdd9..9cd59d64b7f4c 100644 --- a/tests/components/hue_ble/test_config_flow.py +++ b/tests/components/hue_ble/test_config_flow.py @@ -1,62 +1,246 @@ """Test the Hue BLE config flow.""" -from unittest.mock import AsyncMock, patch +from unittest.mock import AsyncMock, PropertyMock, patch from homeassistant import config_entries from homeassistant.components.hue_ble.config_flow import ( CannotConnect, InvalidAuth, NotFound, - ScannerNotAvaliable, + ScannerNotAvailable, ) from homeassistant.components.hue_ble.const import DOMAIN from homeassistant.const import CONF_MAC, CONF_NAME from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType +from . import HUE_BLE_SERVICE_INFO, TEST_DEVICE_MAC, TEST_DEVICE_NAME + +from tests.components.bluetooth import generate_ble_device + async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None: - """Test we get the form.""" + """Test form with good data.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == FlowResultType.FORM assert result["errors"] == {} + with ( + patch( + "homeassistant.components.hue_ble.config_flow.async_ble_device_from_address", + return_value=generate_ble_device(TEST_DEVICE_NAME, TEST_DEVICE_MAC), + ), + patch( + "homeassistant.components.hue_ble.config_flow.async_scanner_count", + return_value=1, + ), + patch( + "homeassistant.components.hue_ble.config_flow.HueBleLight.connect", + return_value=True, + ), + patch( + "homeassistant.components.hue_ble.config_flow.HueBleLight.authenticated", + return_value=True, + new_callable=PropertyMock, + ), + patch( + "homeassistant.components.hue_ble.config_flow.HueBleLight.connected", + return_value=True, + new_callable=PropertyMock, + ), + patch( + "homeassistant.components.hue_ble.config_flow.HueBleLight.poll_state", + return_value=(True, []), + ), + ): + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {CONF_NAME: TEST_DEVICE_NAME, CONF_MAC: TEST_DEVICE_MAC}, + ) + await hass.async_block_till_done() + + assert result["type"] == FlowResultType.CREATE_ENTRY + assert result["title"] == TEST_DEVICE_NAME + assert result["data"] == { + CONF_NAME: TEST_DEVICE_NAME, + CONF_MAC: TEST_DEVICE_MAC, + } + assert len(mock_setup_entry.mock_calls) == 1 + + +async def test_form_no_scanners( + hass: HomeAssistant, mock_setup_entry: AsyncMock +) -> None: + """Test form when no scanners available.""" + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": config_entries.SOURCE_USER} + ) + + with ( + patch( + "homeassistant.components.hue_ble.config_flow.async_ble_device_from_address", + return_value=None, + ), + patch( + "homeassistant.components.hue_ble.config_flow.async_scanner_count", + return_value=0, + ), + ): + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {CONF_NAME: TEST_DEVICE_NAME, CONF_MAC: TEST_DEVICE_MAC}, + ) + + assert result["type"] == FlowResultType.FORM + assert result["errors"] == {"base": "no_scanners"} + with patch( "homeassistant.components.hue_ble.config_flow.validate_input", return_value=True, ): result = await hass.config_entries.flow.async_configure( result["flow_id"], - {CONF_NAME: "Name of the device", CONF_MAC: "aa:bb:cc:dd:ee:ff"}, + {CONF_NAME: TEST_DEVICE_NAME, CONF_MAC: TEST_DEVICE_MAC}, ) await hass.async_block_till_done() assert result["type"] == FlowResultType.CREATE_ENTRY - assert result["title"] == "Name of the device" + assert result["title"] == TEST_DEVICE_NAME assert result["data"] == { - CONF_NAME: "Name of the device", - CONF_MAC: "aa:bb:cc:dd:ee:ff", + CONF_NAME: TEST_DEVICE_NAME, + CONF_MAC: TEST_DEVICE_MAC, } assert len(mock_setup_entry.mock_calls) == 1 -async def test_form_cannot_connect( +async def test_form_device_not_found( hass: HomeAssistant, mock_setup_entry: AsyncMock ) -> None: - """Test we handle when we cannot connect.""" + """Test form when device not found.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) + with ( + patch( + "homeassistant.components.hue_ble.config_flow.async_ble_device_from_address", + return_value=None, + ), + patch( + "homeassistant.components.hue_ble.config_flow.async_scanner_count", + return_value=1, + ), + ): + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {CONF_NAME: TEST_DEVICE_NAME, CONF_MAC: TEST_DEVICE_MAC}, + ) + + assert result["type"] == FlowResultType.FORM + assert result["errors"] == {"base": "not_found"} + with patch( "homeassistant.components.hue_ble.config_flow.validate_input", - side_effect=CannotConnect, + return_value=True, + ): + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {CONF_NAME: TEST_DEVICE_NAME, CONF_MAC: TEST_DEVICE_MAC}, + ) + await hass.async_block_till_done() + + assert result["type"] == FlowResultType.CREATE_ENTRY + assert result["title"] == TEST_DEVICE_NAME + assert result["data"] == { + CONF_NAME: TEST_DEVICE_NAME, + CONF_MAC: TEST_DEVICE_MAC, + } + assert len(mock_setup_entry.mock_calls) == 1 + + +async def test_form_not_authenticated( + hass: HomeAssistant, mock_setup_entry: AsyncMock +) -> None: + """Test form when not authenticated to device (pair failed).""" + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": config_entries.SOURCE_USER} + ) + + with ( + patch( + "homeassistant.components.hue_ble.config_flow.async_ble_device_from_address", + return_value=generate_ble_device(TEST_DEVICE_MAC, TEST_DEVICE_NAME), + ), + patch( + "homeassistant.components.hue_ble.config_flow.HueBleLight.connect", + return_value=True, + ), + patch( + "homeassistant.components.hue_ble.config_flow.HueBleLight.authenticated", + return_value=False, + new_callable=PropertyMock, + ), ): result = await hass.config_entries.flow.async_configure( result["flow_id"], - {CONF_NAME: "Name of the device", CONF_MAC: "aa:bb:cc:dd:ee:ff"}, + {CONF_NAME: TEST_DEVICE_NAME, CONF_MAC: TEST_DEVICE_MAC}, + ) + + assert result["type"] == FlowResultType.FORM + assert result["errors"] == {"base": "invalid_auth"} + + with patch( + "homeassistant.components.hue_ble.config_flow.validate_input", + return_value=True, + ): + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {CONF_NAME: TEST_DEVICE_NAME, CONF_MAC: TEST_DEVICE_MAC}, + ) + await hass.async_block_till_done() + + assert result["type"] == FlowResultType.CREATE_ENTRY + assert result["title"] == TEST_DEVICE_NAME + assert result["data"] == { + CONF_NAME: TEST_DEVICE_NAME, + CONF_MAC: TEST_DEVICE_MAC, + } + assert len(mock_setup_entry.mock_calls) == 1 + + +async def test_form_cannot_connect( + hass: HomeAssistant, mock_setup_entry: AsyncMock +) -> None: + """Test form when device connection fails.""" + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": config_entries.SOURCE_USER} + ) + + with ( + patch( + "homeassistant.components.hue_ble.config_flow.async_ble_device_from_address", + return_value=generate_ble_device(TEST_DEVICE_MAC, TEST_DEVICE_NAME), + ), + patch( + "homeassistant.components.hue_ble.config_flow.HueBleLight.connect", + return_value=True, + ), + patch( + "homeassistant.components.hue_ble.config_flow.HueBleLight.authenticated", + return_value=True, + new_callable=PropertyMock, + ), + patch( + "homeassistant.components.hue_ble.config_flow.HueBleLight.connected", + return_value=False, + new_callable=PropertyMock, + ), + ): + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {CONF_NAME: TEST_DEVICE_NAME, CONF_MAC: TEST_DEVICE_MAC}, ) assert result["type"] == FlowResultType.FORM @@ -68,38 +252,95 @@ async def test_form_cannot_connect( ): result = await hass.config_entries.flow.async_configure( result["flow_id"], - {CONF_NAME: "Name of the device", CONF_MAC: "aa:bb:cc:dd:ee:ff"}, + {CONF_NAME: TEST_DEVICE_NAME, CONF_MAC: TEST_DEVICE_MAC}, ) await hass.async_block_till_done() assert result["type"] == FlowResultType.CREATE_ENTRY - assert result["title"] == "Name of the device" + assert result["title"] == TEST_DEVICE_NAME assert result["data"] == { - CONF_NAME: "Name of the device", - CONF_MAC: "aa:bb:cc:dd:ee:ff", + CONF_NAME: TEST_DEVICE_NAME, + CONF_MAC: TEST_DEVICE_MAC, } assert len(mock_setup_entry.mock_calls) == 1 -async def test_form_not_authenticated( +async def test_form_failed_poll( hass: HomeAssistant, mock_setup_entry: AsyncMock ) -> None: - """Test we handle not being authenticated.""" + """Test form when polling data & metadata fails.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) + with ( + patch( + "homeassistant.components.hue_ble.config_flow.async_ble_device_from_address", + return_value=generate_ble_device(TEST_DEVICE_MAC, TEST_DEVICE_NAME), + ), + patch( + "homeassistant.components.hue_ble.config_flow.HueBleLight.connect", + return_value=True, + ), + patch( + "homeassistant.components.hue_ble.config_flow.HueBleLight.authenticated", + return_value=True, + new_callable=PropertyMock, + ), + patch( + "homeassistant.components.hue_ble.config_flow.HueBleLight.connected", + return_value=True, + new_callable=PropertyMock, + ), + patch( + "homeassistant.components.hue_ble.config_flow.HueBleLight.poll_state", + return_value=(True, ["Error :P"]), + ), + ): + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {CONF_NAME: TEST_DEVICE_NAME, CONF_MAC: TEST_DEVICE_MAC}, + ) + + assert result["type"] == FlowResultType.FORM + assert result["errors"] == {"base": "cannot_connect"} + with patch( "homeassistant.components.hue_ble.config_flow.validate_input", - side_effect=InvalidAuth, + return_value=True, + ): + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {CONF_NAME: TEST_DEVICE_NAME, CONF_MAC: TEST_DEVICE_MAC}, + ) + await hass.async_block_till_done() + + assert result["type"] == FlowResultType.CREATE_ENTRY + assert result["title"] == TEST_DEVICE_NAME + assert result["data"] == { + CONF_NAME: TEST_DEVICE_NAME, + CONF_MAC: TEST_DEVICE_MAC, + } + assert len(mock_setup_entry.mock_calls) == 1 + + +async def test_form_unknown(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None: + """Test form when unknown error.""" + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": config_entries.SOURCE_USER} + ) + + with patch( + "homeassistant.components.hue_ble.config_flow.validate_input", + side_effect=Exception, ): result = await hass.config_entries.flow.async_configure( result["flow_id"], - {CONF_NAME: "Name of the device", CONF_MAC: "aa:bb:cc:dd:ee:ff"}, + {CONF_NAME: TEST_DEVICE_NAME, CONF_MAC: TEST_DEVICE_MAC}, ) assert result["type"] == FlowResultType.FORM - assert result["errors"] == {"base": "invalid_auth"} + assert result["errors"] == {"base": "unknown"} with patch( "homeassistant.components.hue_ble.config_flow.validate_input", @@ -107,35 +348,72 @@ async def test_form_not_authenticated( ): result = await hass.config_entries.flow.async_configure( result["flow_id"], - {CONF_NAME: "Name of the device", CONF_MAC: "aa:bb:cc:dd:ee:ff"}, + {CONF_NAME: TEST_DEVICE_NAME, CONF_MAC: TEST_DEVICE_MAC}, ) await hass.async_block_till_done() assert result["type"] == FlowResultType.CREATE_ENTRY - assert result["title"] == "Name of the device" + assert result["title"] == TEST_DEVICE_NAME assert result["data"] == { - CONF_NAME: "Name of the device", - CONF_MAC: "aa:bb:cc:dd:ee:ff", + CONF_NAME: TEST_DEVICE_NAME, + CONF_MAC: TEST_DEVICE_MAC, } assert len(mock_setup_entry.mock_calls) == 1 -async def test_form_no_scanners( +async def test_bluetooth_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None: + """Test bluetooth discovery form.""" + + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": config_entries.SOURCE_BLUETOOTH}, + data=HUE_BLE_SERVICE_INFO, + ) + assert result["type"] is FlowResultType.FORM + assert result["step_id"] == "confirm" + + with patch( + "homeassistant.components.hue_ble.config_flow.validate_input", + return_value=True, + ): + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {}, + ) + await hass.async_block_till_done() + + assert result["type"] is FlowResultType.CREATE_ENTRY + assert result["title"] == TEST_DEVICE_NAME + assert result["data"] == { + CONF_NAME: TEST_DEVICE_NAME, + CONF_MAC: TEST_DEVICE_MAC, + } + + assert len(mock_setup_entry.mock_calls) == 1 + + +async def test_bluetooth_form_no_scanners( hass: HomeAssistant, mock_setup_entry: AsyncMock ) -> None: - """Test we handle no scanners.""" + """Test bluetooth discovery form when no scanners available.""" + result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_USER} + DOMAIN, + context={"source": config_entries.SOURCE_BLUETOOTH}, + data=HUE_BLE_SERVICE_INFO, ) + assert result["type"] is FlowResultType.FORM + assert result["step_id"] == "confirm" with patch( "homeassistant.components.hue_ble.config_flow.validate_input", - side_effect=ScannerNotAvaliable, + side_effect=ScannerNotAvailable, ): result = await hass.config_entries.flow.async_configure( result["flow_id"], - {CONF_NAME: "Name of the device", CONF_MAC: "aa:bb:cc:dd:ee:ff"}, + {}, ) + await hass.async_block_till_done() assert result["type"] == FlowResultType.FORM assert result["errors"] == {"base": "no_scanners"} @@ -146,24 +424,32 @@ async def test_form_no_scanners( ): result = await hass.config_entries.flow.async_configure( result["flow_id"], - {CONF_NAME: "Name of the device", CONF_MAC: "aa:bb:cc:dd:ee:ff"}, + {}, ) await hass.async_block_till_done() - assert result["type"] == FlowResultType.CREATE_ENTRY - assert result["title"] == "Name of the device" + assert result["type"] is FlowResultType.CREATE_ENTRY + assert result["title"] == TEST_DEVICE_NAME assert result["data"] == { - CONF_NAME: "Name of the device", - CONF_MAC: "aa:bb:cc:dd:ee:ff", + CONF_NAME: TEST_DEVICE_NAME, + CONF_MAC: TEST_DEVICE_MAC, } + assert len(mock_setup_entry.mock_calls) == 1 -async def test_form_not_found(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None: - """Test we handle light not found.""" +async def test_bluetooth_form_device_not_found( + hass: HomeAssistant, mock_setup_entry: AsyncMock +) -> None: + """Test bluetooth discovery form when device not found.""" + result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_USER} + DOMAIN, + context={"source": config_entries.SOURCE_BLUETOOTH}, + data=HUE_BLE_SERVICE_INFO, ) + assert result["type"] is FlowResultType.FORM + assert result["step_id"] == "confirm" with patch( "homeassistant.components.hue_ble.config_flow.validate_input", @@ -171,8 +457,9 @@ async def test_form_not_found(hass: HomeAssistant, mock_setup_entry: AsyncMock) ): result = await hass.config_entries.flow.async_configure( result["flow_id"], - {CONF_NAME: "Name of the device", CONF_MAC: "aa:bb:cc:dd:ee:ff"}, + {}, ) + await hass.async_block_till_done() assert result["type"] == FlowResultType.FORM assert result["errors"] == {"base": "not_found"} @@ -183,24 +470,124 @@ async def test_form_not_found(hass: HomeAssistant, mock_setup_entry: AsyncMock) ): result = await hass.config_entries.flow.async_configure( result["flow_id"], - {CONF_NAME: "Name of the device", CONF_MAC: "aa:bb:cc:dd:ee:ff"}, + {}, ) await hass.async_block_till_done() - assert result["type"] == FlowResultType.CREATE_ENTRY - assert result["title"] == "Name of the device" + assert result["type"] is FlowResultType.CREATE_ENTRY + assert result["title"] == TEST_DEVICE_NAME assert result["data"] == { - CONF_NAME: "Name of the device", - CONF_MAC: "aa:bb:cc:dd:ee:ff", + CONF_NAME: TEST_DEVICE_NAME, + CONF_MAC: TEST_DEVICE_MAC, } + assert len(mock_setup_entry.mock_calls) == 1 -async def test_form_unknown(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None: - """Test we handle an unknown error.""" +async def test_bluetooth_form_not_authenticated( + hass: HomeAssistant, mock_setup_entry: AsyncMock +) -> None: + """Test bluetooth discovery form when not authenticated to device (pair failed).""" + result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_USER} + DOMAIN, + context={"source": config_entries.SOURCE_BLUETOOTH}, + data=HUE_BLE_SERVICE_INFO, + ) + assert result["type"] is FlowResultType.FORM + assert result["step_id"] == "confirm" + + with patch( + "homeassistant.components.hue_ble.config_flow.validate_input", + side_effect=InvalidAuth, + ): + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {}, + ) + await hass.async_block_till_done() + + assert result["type"] == FlowResultType.FORM + assert result["errors"] == {"base": "invalid_auth"} + + with patch( + "homeassistant.components.hue_ble.config_flow.validate_input", + return_value=True, + ): + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {}, + ) + await hass.async_block_till_done() + + assert result["type"] is FlowResultType.CREATE_ENTRY + assert result["title"] == TEST_DEVICE_NAME + assert result["data"] == { + CONF_NAME: TEST_DEVICE_NAME, + CONF_MAC: TEST_DEVICE_MAC, + } + + assert len(mock_setup_entry.mock_calls) == 1 + + +async def test_bluetooth_form_cannot_connect( + hass: HomeAssistant, mock_setup_entry: AsyncMock +) -> None: + """Test bluetooth discovery form when connection to device fails.""" + + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": config_entries.SOURCE_BLUETOOTH}, + data=HUE_BLE_SERVICE_INFO, ) + assert result["type"] is FlowResultType.FORM + assert result["step_id"] == "confirm" + + with patch( + "homeassistant.components.hue_ble.config_flow.validate_input", + side_effect=CannotConnect, + ): + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {}, + ) + await hass.async_block_till_done() + + assert result["type"] == FlowResultType.FORM + assert result["errors"] == {"base": "cannot_connect"} + + with patch( + "homeassistant.components.hue_ble.config_flow.validate_input", + return_value=True, + ): + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {}, + ) + await hass.async_block_till_done() + + assert result["type"] is FlowResultType.CREATE_ENTRY + assert result["title"] == TEST_DEVICE_NAME + assert result["data"] == { + CONF_NAME: TEST_DEVICE_NAME, + CONF_MAC: TEST_DEVICE_MAC, + } + + assert len(mock_setup_entry.mock_calls) == 1 + + +async def test_bluetooth_form_unknown( + hass: HomeAssistant, mock_setup_entry: AsyncMock +) -> None: + """Test bluetooth discovery form when unknown error.""" + + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": config_entries.SOURCE_BLUETOOTH}, + data=HUE_BLE_SERVICE_INFO, + ) + assert result["type"] is FlowResultType.FORM + assert result["step_id"] == "confirm" with patch( "homeassistant.components.hue_ble.config_flow.validate_input", @@ -208,8 +595,9 @@ async def test_form_unknown(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> ): result = await hass.config_entries.flow.async_configure( result["flow_id"], - {CONF_NAME: "Name of the device", CONF_MAC: "aa:bb:cc:dd:ee:ff"}, + {}, ) + await hass.async_block_till_done() assert result["type"] == FlowResultType.FORM assert result["errors"] == {"base": "unknown"} @@ -220,14 +608,15 @@ async def test_form_unknown(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> ): result = await hass.config_entries.flow.async_configure( result["flow_id"], - {CONF_NAME: "Name of the device", CONF_MAC: "aa:bb:cc:dd:ee:ff"}, + {}, ) await hass.async_block_till_done() - assert result["type"] == FlowResultType.CREATE_ENTRY - assert result["title"] == "Name of the device" + assert result["type"] is FlowResultType.CREATE_ENTRY + assert result["title"] == TEST_DEVICE_NAME assert result["data"] == { - CONF_NAME: "Name of the device", - CONF_MAC: "aa:bb:cc:dd:ee:ff", + CONF_NAME: TEST_DEVICE_NAME, + CONF_MAC: TEST_DEVICE_MAC, } + assert len(mock_setup_entry.mock_calls) == 1