@@ -75,8 +75,8 @@ async def test_import_flow(hass, pyscript_bypass_setup):
75
75
assert result ["type" ] == data_entry_flow .RESULT_TYPE_CREATE_ENTRY
76
76
77
77
78
- async def test_import_flow_update_entry (hass ):
79
- """Test import config flow updates existing entry."""
78
+ async def test_import_flow_update_allow_all_imports (hass ):
79
+ """Test import config flow updates existing entry when `allow_all_imports` has changed ."""
80
80
result = await hass .config_entries .flow .async_init (
81
81
DOMAIN , context = {"source" : SOURCE_IMPORT }, data = PYSCRIPT_SCHEMA ({})
82
82
)
@@ -91,6 +91,36 @@ async def test_import_flow_update_entry(hass):
91
91
assert result ["reason" ] == "updated_entry"
92
92
93
93
94
+ async def test_import_flow_update_apps_from_none (hass ):
95
+ """Test import config flow updates existing entry when `apps` has changed from None to something."""
96
+ result = await hass .config_entries .flow .async_init (
97
+ DOMAIN , context = {"source" : SOURCE_IMPORT }, data = PYSCRIPT_SCHEMA ({})
98
+ )
99
+
100
+ assert result ["type" ] == data_entry_flow .RESULT_TYPE_CREATE_ENTRY
101
+
102
+ result = await hass .config_entries .flow .async_init (
103
+ DOMAIN , context = {"source" : SOURCE_IMPORT }, data = {"apps" : {"test_app" : {"param" : 1 }}}
104
+ )
105
+
106
+ assert result ["type" ] == data_entry_flow .RESULT_TYPE_ABORT
107
+ assert result ["reason" ] == "updated_entry"
108
+
109
+
110
+ async def test_import_flow_update_apps_to_none (hass ):
111
+ """Test import config flow updates existing entry when `apps` has changed from something to None."""
112
+ result = await hass .config_entries .flow .async_init (
113
+ DOMAIN , context = {"source" : SOURCE_IMPORT }, data = PYSCRIPT_SCHEMA ({"apps" : {"test_app" : {"param" : 1 }}})
114
+ )
115
+
116
+ assert result ["type" ] == data_entry_flow .RESULT_TYPE_CREATE_ENTRY
117
+
118
+ result = await hass .config_entries .flow .async_init (DOMAIN , context = {"source" : SOURCE_IMPORT }, data = {})
119
+
120
+ assert result ["type" ] == data_entry_flow .RESULT_TYPE_ABORT
121
+ assert result ["reason" ] == "updated_entry"
122
+
123
+
94
124
async def test_import_flow_no_update (hass ):
95
125
"""Test import config flow doesn't update existing entry when data is same."""
96
126
result = await hass .config_entries .flow .async_init (
0 commit comments