mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Improve onewire options flow tests (#135109)
This commit is contained in:
parent
0e52ea482f
commit
02e30edc6c
@ -7,10 +7,7 @@ rules:
|
||||
unique-config-entry:
|
||||
status: done
|
||||
comment: unique ID is not available, but duplicates are prevented based on host/port
|
||||
config-flow-test-coverage:
|
||||
status: todo
|
||||
comment: >
|
||||
Let's have test_user_options_empty_selection end in CREATE_ENTRY
|
||||
config-flow-test-coverage: done
|
||||
runtime-data: done
|
||||
test-before-setup: done
|
||||
appropriate-polling: done
|
||||
|
@ -215,7 +215,7 @@ async def test_user_options_clear(
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("filled_device_registry")
|
||||
async def test_user_options_empty_selection(
|
||||
async def test_user_options_empty_selection_recovery(
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test leaving the selection of devices empty."""
|
||||
@ -229,7 +229,7 @@ async def test_user_options_empty_selection(
|
||||
"28.222222222223": False,
|
||||
}
|
||||
|
||||
# Verify that an empty selection does not modify the options
|
||||
# Verify that an empty selection shows the form again
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={INPUT_ENTRY_DEVICE_SELECTION: []},
|
||||
@ -238,6 +238,25 @@ async def test_user_options_empty_selection(
|
||||
assert result["step_id"] == "device_selection"
|
||||
assert result["errors"] == {"base": "device_not_selected"}
|
||||
|
||||
# Verify that a single selected device to configure comes back as a form with the device to configure
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={INPUT_ENTRY_DEVICE_SELECTION: ["28.111111111111"]},
|
||||
)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["description_placeholders"]["sensor_id"] == "28.111111111111"
|
||||
|
||||
# Verify that the setting for the device comes back as default when no input is given
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={},
|
||||
)
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert (
|
||||
result["data"]["device_options"]["28.111111111111"]["precision"]
|
||||
== "temperature"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("filled_device_registry")
|
||||
async def test_user_options_set_single(
|
||||
|
Loading…
x
Reference in New Issue
Block a user