mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +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:
|
unique-config-entry:
|
||||||
status: done
|
status: done
|
||||||
comment: unique ID is not available, but duplicates are prevented based on host/port
|
comment: unique ID is not available, but duplicates are prevented based on host/port
|
||||||
config-flow-test-coverage:
|
config-flow-test-coverage: done
|
||||||
status: todo
|
|
||||||
comment: >
|
|
||||||
Let's have test_user_options_empty_selection end in CREATE_ENTRY
|
|
||||||
runtime-data: done
|
runtime-data: done
|
||||||
test-before-setup: done
|
test-before-setup: done
|
||||||
appropriate-polling: done
|
appropriate-polling: done
|
||||||
|
@ -215,7 +215,7 @@ async def test_user_options_clear(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures("filled_device_registry")
|
@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
|
hass: HomeAssistant, config_entry: MockConfigEntry
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test leaving the selection of devices empty."""
|
"""Test leaving the selection of devices empty."""
|
||||||
@ -229,7 +229,7 @@ async def test_user_options_empty_selection(
|
|||||||
"28.222222222223": False,
|
"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 = await hass.config_entries.options.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={INPUT_ENTRY_DEVICE_SELECTION: []},
|
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["step_id"] == "device_selection"
|
||||||
assert result["errors"] == {"base": "device_not_selected"}
|
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")
|
@pytest.mark.usefixtures("filled_device_registry")
|
||||||
async def test_user_options_set_single(
|
async def test_user_options_set_single(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user