@@ -75,8 +75,8 @@ async def test_import_flow(hass, pyscript_bypass_setup):
7575 assert result ["type" ] == data_entry_flow .RESULT_TYPE_CREATE_ENTRY
7676
7777
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 ."""
8080 result = await hass .config_entries .flow .async_init (
8181 DOMAIN , context = {"source" : SOURCE_IMPORT }, data = PYSCRIPT_SCHEMA ({})
8282 )
@@ -91,6 +91,36 @@ async def test_import_flow_update_entry(hass):
9191 assert result ["reason" ] == "updated_entry"
9292
9393
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+
94124async def test_import_flow_no_update (hass ):
95125 """Test import config flow doesn't update existing entry when data is same."""
96126 result = await hass .config_entries .flow .async_init (
0 commit comments