@@ -2391,12 +2391,24 @@ async def test_reconfig_success_with_new_ip_same_name(
23912391
23922392
23932393@pytest .mark .usefixtures ("mock_zeroconf" , "mock_setup_entry" )
2394- async def test_reconfig_can_save_changed_unreachable_host (
2395- hass : HomeAssistant , mock_client : APIClient
2394+ @pytest .mark .parametrize (
2395+ ("host" , "error" , "placeholder_host" ),
2396+ [
2397+ ("127.0.0.2" , APIConnectionError , "127.0.0.2" ),
2398+ ("2001:db8::2" , ResolveAPIError , "[2001:db8::2]" ),
2399+ ],
2400+ )
2401+ async def test_reconfig_can_save_changed_unreachable_connection (
2402+ hass : HomeAssistant ,
2403+ mock_client : APIClient ,
2404+ host : str ,
2405+ error : type [Exception ],
2406+ placeholder_host : str ,
23962407) -> None :
2397- """Test reconfig can save a changed host when the device is unreachable."""
2408+ """Test reconfig can save changed connection details when unreachable."""
23982409 entry = MockConfigEntry (
23992410 domain = DOMAIN ,
2411+ title = "Kitchen Sensor" ,
24002412 data = {
24012413 CONF_HOST : "127.0.0.1" ,
24022414 CONF_PORT : 6053 ,
@@ -2410,17 +2422,17 @@ async def test_reconfig_can_save_changed_unreachable_host(
24102422
24112423 result = await entry .start_reconfigure_flow (hass )
24122424
2413- mock_client .device_info .side_effect = APIConnectionError
2425+ mock_client .device_info .side_effect = error
24142426 result = await hass .config_entries .flow .async_configure (
2415- result ["flow_id" ], user_input = {CONF_HOST : "127.0.0.2" , CONF_PORT : 6053 }
2427+ result ["flow_id" ], user_input = {CONF_HOST : host , CONF_PORT : 6053 }
24162428 )
24172429
24182430 assert result ["type" ] is FlowResultType .FORM
24192431 assert result ["step_id" ] == "reconfigure_confirm_unreachable"
24202432 assert result ["description_placeholders" ] == {
2421- "host" : "127.0.0.2" ,
2422- "name" : "test " ,
2423- "port" : 6053 ,
2433+ "host" : placeholder_host ,
2434+ "name" : "Kitchen Sensor " ,
2435+ "port" : " 6053" ,
24242436 }
24252437 assert entry .data [CONF_HOST ] == "127.0.0.1"
24262438
@@ -2431,7 +2443,7 @@ async def test_reconfig_can_save_changed_unreachable_host(
24312443 assert result ["type" ] is FlowResultType .ABORT
24322444 assert result ["reason" ] == "reconfigure_successful"
24332445 assert entry .data == {
2434- CONF_HOST : "127.0.0.2" ,
2446+ CONF_HOST : host ,
24352447 CONF_PORT : 6053 ,
24362448 CONF_PASSWORD : "" ,
24372449 CONF_DEVICE_NAME : "test" ,
0 commit comments