From 88b9a518115a47c51ae4d6143cab08d04b08876c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 22 Jul 2022 17:43:13 -0500 Subject: [PATCH] Fix inkbird config flow tests to correctly test discovery and user flow (#75638) * Fix inkbird config flow tests to correctly test discovery and user flow * Fix inkbird config flow tests to correctly test discovery and user flow --- tests/components/inkbird/test_config_flow.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/components/inkbird/test_config_flow.py b/tests/components/inkbird/test_config_flow.py index 86097aec208..c1f8b3ef545 100644 --- a/tests/components/inkbird/test_config_flow.py +++ b/tests/components/inkbird/test_config_flow.py @@ -141,12 +141,24 @@ async def test_async_step_user_takes_precedence_over_discovery(hass): assert result["step_id"] == "bluetooth_confirm" with patch( - "homeassistant.components.sensorpush.async_setup_entry", return_value=True + "homeassistant.components.inkbird.config_flow.async_discovered_service_info", + return_value=[SPS_SERVICE_INFO], ): + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": config_entries.SOURCE_USER}, + ) + assert result["type"] == FlowResultType.FORM + + with patch("homeassistant.components.inkbird.async_setup_entry", return_value=True): result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], user_input={} + result["flow_id"], + user_input={"address": "61DE521B-F0BF-9F44-64D4-75BBE1738105"}, ) assert result2["type"] == FlowResultType.CREATE_ENTRY assert result2["title"] == "IBS-TH 75BBE1738105" assert result2["data"] == {} assert result2["result"].unique_id == "61DE521B-F0BF-9F44-64D4-75BBE1738105" + + # Verify the original one was aborted + assert not hass.config_entries.flow.async_progress(DOMAIN)