Abort rtsp_to_webrtc config flow on error during add-on discovery (#64500)

This commit is contained in:
Allen Porter 2022-01-20 01:14:13 -08:00 committed by GitHub
parent a1ed2a57e9
commit 86dbe068e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -90,7 +90,7 @@ class RTSPToWebRTCConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
port = self._hassio_discovery[CONF_PORT]
url = f"http://{host}:{port}"
if error_code := await self._test_connection(url):
errors = {"base": error_code}
return self.async_abort(reason=error_code)
if user_input is None or errors:
# Show initial confirmation or errors from server validation

View File

@ -19,7 +19,9 @@
"server_unreachable": "Unable to communicate with RTSPtoWebRTC server. Check logs for more information."
},
"abort": {
"single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]"
"single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]",
"server_failure": "RTSPtoWebRTC server returned an error. Check logs for more information.",
"server_unreachable": "Unable to communicate with RTSPtoWebRTC server. Check logs for more information."
}
}
}

View File

@ -210,6 +210,5 @@ async def test_hassio_discovery_server_failure(hass: HomeAssistant) -> None:
side_effect=rtsp_to_webrtc.exceptions.ResponseError(),
):
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
assert result.get("type") == "form"
assert result.get("step_id") == "hassio_confirm"
assert result.get("errors") == {"base": "server_failure"}
assert result.get("type") == "abort"
assert result.get("reason") == "server_failure"