From 7008dfea46955df3bb9d055a10bbfa0fe2dacaf8 Mon Sep 17 00:00:00 2001 From: Andreas Hartel Date: Wed, 10 Aug 2022 17:08:24 +0200 Subject: [PATCH] add 2 more tests for 503 and 408 retries --- tests/test_errors.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/test_errors.py b/tests/test_errors.py index 82c6236..2dc34bf 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -388,7 +388,6 @@ def httpserver_listen_address(): def test_timeout(httpserver): - def handler(foo): time.sleep(2) @@ -400,3 +399,18 @@ def handler(foo): host="http://localhost:8000/", token="AA_TOKEN", request_timeout_seconds=0.1 ) + +def test_retry_on_503(httpserver): + httpserver.expect_request("/version").respond_with_data("busy", status=503) + + """Ensures Timeouts works. AlephAlphaClient constructor calls version endpoint.""" + with pytest.raises(requests.exceptions.RetryError): + AlephAlphaClient(host="http://localhost:8000/", token="AA_TOKEN") + + +def test_retry_on_408(httpserver): + httpserver.expect_request("/version").respond_with_data("busy", status=408) + + """Ensures Timeouts works. AlephAlphaClient constructor calls version endpoint.""" + with pytest.raises(requests.exceptions.RetryError): + AlephAlphaClient(host="http://localhost:8000/", token="AA_TOKEN")