tests: aemet: check CONF_STATION_UPDATES default form value

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
pull/111214/head
Álvaro Fernández Rojas 2024-02-24 20:03:10 +01:00
parent 1b105444f5
commit f0f95da68f
1 changed files with 12 additions and 0 deletions

View File

@ -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: async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
"""Test that the form is served with valid input.""" """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["type"] == data_entry_flow.FlowResultType.FORM
assert result["step_id"] == "init" 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 = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={CONF_STATION_UPDATES: False} result["flow_id"], user_input={CONF_STATION_UPDATES: False}