From 145c6163a4b013235463d5d239c51df71d90e022 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 20 Feb 2024 16:08:06 -0600 Subject: [PATCH] Fix race in gardena_bluetooth config flow tests (#111042) --- .../snapshots/test_config_flow.ambr | 14 +++++++------- .../gardena_bluetooth/test_config_flow.py | 9 ++++----- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/tests/components/gardena_bluetooth/snapshots/test_config_flow.ambr b/tests/components/gardena_bluetooth/snapshots/test_config_flow.ambr index a2fe4b63cf8..98cba151c52 100644 --- a/tests/components/gardena_bluetooth/snapshots/test_config_flow.ambr +++ b/tests/components/gardena_bluetooth/snapshots/test_config_flow.ambr @@ -1,17 +1,17 @@ # serializer version: 1 # name: test_bluetooth FlowResultSnapshot({ - 'data_schema': None, - 'description_placeholders': dict({ - 'name': 'Gardena Water Computer', + 'context': dict({ + 'confirm_only': True, + 'source': 'bluetooth', + 'title_placeholders': dict({ + 'name': 'Gardena Water Computer', + }), + 'unique_id': '00000000-0000-0000-0000-000000000001', }), - 'errors': None, 'flow_id': , 'handler': 'gardena_bluetooth', - 'last_step': None, - 'preview': None, 'step_id': 'confirm', - 'type': , }) # --- # name: test_bluetooth.1 diff --git a/tests/components/gardena_bluetooth/test_config_flow.py b/tests/components/gardena_bluetooth/test_config_flow.py index d533d1ff2da..bcbd27e50a7 100644 --- a/tests/components/gardena_bluetooth/test_config_flow.py +++ b/tests/components/gardena_bluetooth/test_config_flow.py @@ -100,13 +100,12 @@ async def test_bluetooth( ) -> None: """Test bluetooth device discovery.""" + # Inject the service info will trigger the flow to start inject_bluetooth_service_info(hass, WATER_TIMER_SERVICE_INFO) + await hass.async_block_till_done() + + result = next(iter(hass.config_entries.flow.async_progress_by_handler(DOMAIN))) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_BLUETOOTH}, - data=WATER_TIMER_SERVICE_INFO, - ) assert result == snapshot result = await hass.config_entries.flow.async_configure(