From f0f95da68fa5b2d8964b0a45cbd9939843deccfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Sat, 24 Feb 2024 20:03:10 +0100 Subject: [PATCH] tests: aemet: check CONF_STATION_UPDATES default form value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Álvaro Fernández Rojas --- tests/components/aemet/test_config_flow.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/components/aemet/test_config_flow.py b/tests/components/aemet/test_config_flow.py index 0caacf4e4c0..765d6003b59 100644 --- a/tests/components/aemet/test_config_flow.py +++ b/tests/components/aemet/test_config_flow.py @@ -25,6 +25,14 @@ CONFIG = { } +def _get_schema_default(schema, key_name): + """Iterate schema to find a key.""" + for schema_key in schema: + if schema_key == key_name: + return schema_key.default() + raise KeyError(f"{key_name} not found in schema") + + async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None: """Test that the form is served with valid input.""" @@ -85,6 +93,10 @@ async def test_form_options( assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["step_id"] == "init" + assert ( + _get_schema_default(result["data_schema"].schema, CONF_STATION_UPDATES) + is True + ) result = await hass.config_entries.options.async_configure( result["flow_id"], user_input={CONF_STATION_UPDATES: False}