Skip to content

Commit 6bda2c1

Browse files
committed
add tests to ensure that allow_all_imports updates are handled properly for user vs import updates
1 parent eb1abd1 commit 6bda2c1

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/test_config_flow.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,42 @@ async def test_import_flow_no_update(hass):
135135

136136
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
137137
assert result["reason"] == "already_configured_service"
138+
139+
140+
async def test_import_flow_update_user(hass):
141+
"""Test import config flow update excludes `allow_all_imports` from being updated when updated entry was a user entry."""
142+
result = await hass.config_entries.flow.async_init(
143+
DOMAIN, context={"source": SOURCE_USER}, data=PYSCRIPT_SCHEMA({CONF_ALLOW_ALL_IMPORTS: True})
144+
)
145+
146+
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
147+
148+
result = await hass.config_entries.flow.async_init(
149+
DOMAIN, context={"source": SOURCE_IMPORT}, data={"apps": {"test_app": {"param": 1}}}
150+
)
151+
152+
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
153+
assert result["reason"] == "updated_entry"
154+
155+
hass.config_entries.async_entries(DOMAIN)[0].data == {
156+
CONF_ALLOW_ALL_IMPORTS: True,
157+
"apps": {"test_app": {"param": 1}},
158+
}
159+
160+
161+
async def test_import_flow_update_import(hass):
162+
"""Test import config flow update includes `allow_all_imports` in update when updated entry was imported entry."""
163+
result = await hass.config_entries.flow.async_init(
164+
DOMAIN, context={"source": SOURCE_IMPORT}, data=PYSCRIPT_SCHEMA({CONF_ALLOW_ALL_IMPORTS: True})
165+
)
166+
167+
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
168+
169+
result = await hass.config_entries.flow.async_init(
170+
DOMAIN, context={"source": SOURCE_IMPORT}, data={"apps": {"test_app": {"param": 1}}}
171+
)
172+
173+
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
174+
assert result["reason"] == "updated_entry"
175+
176+
hass.config_entries.async_entries(DOMAIN)[0].data == {"apps": {"test_app": {"param": 1}}}

0 commit comments

Comments
 (0)