diff --git a/homeassistant/components/aemet/config_flow.py b/homeassistant/components/aemet/config_flow.py index ac51c997907..bb73311aa55 100644 --- a/homeassistant/components/aemet/config_flow.py +++ b/homeassistant/components/aemet/config_flow.py @@ -21,7 +21,7 @@ from .const import CONF_STATION_UPDATES, DEFAULT_NAME, DOMAIN OPTIONS_SCHEMA = vol.Schema( { - vol.Required(CONF_STATION_UPDATES): bool, + vol.Required(CONF_STATION_UPDATES, default=True): bool, } ) OPTIONS_FLOW = { diff --git a/tests/components/aemet/test_config_flow.py b/tests/components/aemet/test_config_flow.py index 0caacf4e4c0..d4cedcaf3d0 100644 --- a/tests/components/aemet/test_config_flow.py +++ b/tests/components/aemet/test_config_flow.py @@ -59,9 +59,14 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None: assert len(mock_setup_entry.mock_calls) == 1 +@pytest.mark.parametrize( + ("user_input", "expected"), [({}, True), ({CONF_STATION_UPDATES: False}, False)] +) async def test_form_options( hass: HomeAssistant, freezer: FrozenDateTimeFactory, + user_input: dict[str, bool], + expected: bool, ) -> None: """Test the form options.""" @@ -87,30 +92,12 @@ async def test_form_options( assert result["step_id"] == "init" result = await hass.config_entries.options.async_configure( - result["flow_id"], user_input={CONF_STATION_UPDATES: False} + result["flow_id"], user_input=user_input ) assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert entry.options == { - CONF_STATION_UPDATES: False, - } - - await hass.async_block_till_done() - - assert entry.state is ConfigEntryState.LOADED - - result = await hass.config_entries.options.async_init(entry.entry_id) - - 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_STATION_UPDATES: True} - ) - - assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY - assert entry.options == { - CONF_STATION_UPDATES: True, + CONF_STATION_UPDATES: expected, } await hass.async_block_till_done()