From 2464232f24b0c7cb71d61b9967d9cb9431ce56c6 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Thu, 5 Oct 2023 13:23:59 +0200 Subject: [PATCH] Fix call to API in airnow option flow tests (#101457) --- tests/components/airnow/test_config_flow.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/components/airnow/test_config_flow.py b/tests/components/airnow/test_config_flow.py index f62fc9aee22..f4a0fdeec1e 100644 --- a/tests/components/airnow/test_config_flow.py +++ b/tests/components/airnow/test_config_flow.py @@ -1,5 +1,5 @@ """Test the AirNow config flow.""" -from unittest.mock import AsyncMock +from unittest.mock import AsyncMock, patch from pyairnow.errors import AirNowError, EmptyResponseError, InvalidKeyError import pytest @@ -142,12 +142,18 @@ async def test_options_flow(hass: HomeAssistant, setup_airnow) -> None: assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["step_id"] == "init" - result = await hass.config_entries.options.async_configure( - result["flow_id"], - user_input={CONF_RADIUS: 25}, - ) + with patch( + "homeassistant.components.airnow.async_setup_entry", + return_value=True, + ) as mock_setup_entry: + result = await hass.config_entries.options.async_configure( + result["flow_id"], + user_input={CONF_RADIUS: 25}, + ) + await hass.async_block_till_done() assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert config_entry.options == { CONF_RADIUS: 25, } + assert len(mock_setup_entry.mock_calls) == 1