@@ -135,3 +135,42 @@ async def test_import_flow_no_update(hass):
135
135
136
136
assert result ["type" ] == data_entry_flow .RESULT_TYPE_ABORT
137
137
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