Handle CLI request errors and backend whisper timeout
This commit is contained in:
@@ -44,3 +44,20 @@ def test_format_http_error_with_empty_body() -> None:
|
||||
response = httpx.Response(500, text="", request=request)
|
||||
message = main.format_http_error(response, "http://localhost:8000/transcriptions")
|
||||
assert message == "HTTP 500 from http://localhost:8000/transcriptions: <empty response body>"
|
||||
|
||||
|
||||
def test_format_request_error_timeout() -> None:
|
||||
request = httpx.Request("POST", "http://localhost:8000/transcriptions")
|
||||
exc = httpx.ReadTimeout("read timed out", request=request)
|
||||
message = main.format_request_error(exc, "http://localhost:8000/transcriptions")
|
||||
assert message == "Request to http://localhost:8000/transcriptions timed out."
|
||||
|
||||
|
||||
def test_format_request_error_network_failure() -> None:
|
||||
request = httpx.Request("POST", "http://localhost:8000/transcriptions")
|
||||
exc = httpx.ConnectError("connection refused", request=request)
|
||||
message = main.format_request_error(exc, "http://localhost:8000/transcriptions")
|
||||
assert (
|
||||
message
|
||||
== "Request to http://localhost:8000/transcriptions failed: connection refused"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user