Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/testErrorHandling.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def test_weird_error(self):
def test_timeout_raises_seatsio_exception(self):
from seatsio.httpClient import HttpClient
try:
client = HttpClient("https://httpbin.seatsio.net", "aSecretKey", None, 0, timeout=0.1)
client = HttpClient("https://httpbingo.org", "aSecretKey", None, 0, timeout=0.1)
client.url("/delay/1").get()
self.fail("expected exception")
except SeatsioException as e:
assert_that(e.message).is_equal_to("Error while executing GET https://httpbin.seatsio.net/delay/1")
assert_that(e.message).is_equal_to("Error while executing GET https://httpbingo.org/delay/1")
assert_that(e.cause).is_not_none()
22 changes: 11 additions & 11 deletions tests/testExponentialBackoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,60 +11,60 @@ class ExponentialBackoffTest(SeatsioClientTest):
def test_aborts_eventually_if_server_keeps_returning_429_get(self):
start = time.time()
try:
client = HttpClient("https://httpbin.seatsio.net", "aSecretKey", None, 5)
client = HttpClient("https://httpbingo.org", "aSecretKey", None, 5)
client.url("/status/429").get()
raise Exception("Should have failed")
except RateLimitExceededException as e:
assert_that(e.message).is_equal_to("Error while executing GET https://httpbin.seatsio.net/status/429")
assert_that(e.message).is_equal_to("Error while executing GET https://httpbingo.org/status/429")
wait_time = int(time.time() - start)
assert_that(wait_time).is_between(10, 20)

def test_aborts_eventually_if_server_keeps_returning_429_post(self):
start = time.time()
try:
client = HttpClient("https://httpbin.seatsio.net", "aSecretKey", None, 5)
client = HttpClient("https://httpbingo.org", "aSecretKey", None, 5)
client.url("/status/429").post()
raise Exception("Should have failed")
except RateLimitExceededException as e:
assert_that(e.message).is_equal_to("Error while executing POST https://httpbin.seatsio.net/status/429")
assert_that(e.message).is_equal_to("Error while executing POST https://httpbingo.org/status/429")
wait_time = int(time.time() - start)
assert_that(wait_time).is_between(10, 20)

def test_aborts_eventually_if_server_keeps_returning_429_delete(self):
start = time.time()
try:
client = HttpClient("https://httpbin.seatsio.net", "aSecretKey", None, 5)
client = HttpClient("https://httpbingo.org", "aSecretKey", None, 5)
client.url("/status/429").delete()
raise Exception("Should have failed")
except RateLimitExceededException as e:
assert_that(e.message).is_equal_to("Error while executing DELETE https://httpbin.seatsio.net/status/429")
assert_that(e.message).is_equal_to("Error while executing DELETE https://httpbingo.org/status/429")
wait_time = int(time.time() - start)
assert_that(wait_time).is_between(10, 20)

def test_aborts_directly_if_server_returns_other_error_than_429(self):
start = time.time()
try:
client = HttpClient("https://httpbin.seatsio.net", "aSecretKey", None, 5)
client = HttpClient("https://httpbingo.org", "aSecretKey", None, 5)
client.url("/status/400").get()
raise Exception("Should have failed")
except SeatsioException as e:
assert_that(e.message).is_equal_to("Error while executing GET https://httpbin.seatsio.net/status/400")
assert_that(e.message).is_equal_to("Error while executing GET https://httpbingo.org/status/400")
wait_time = int(time.time() - start)
assert_that(wait_time).is_between(0, 5)

def test_aborts_directly_if_server_returns_429_but_max_retries_0(self):
start = time.time()
try:
client = HttpClient("https://httpbin.seatsio.net", "aSecretKey", None, 0)
client = HttpClient("https://httpbingo.org", "aSecretKey", None, 0)
client.url("/status/429").get()
raise Exception("Should have failed")
except RateLimitExceededException as e:
assert_that(e.message).is_equal_to("Error while executing GET https://httpbin.seatsio.net/status/429")
assert_that(e.message).is_equal_to("Error while executing GET https://httpbingo.org/status/429")
wait_time = int(time.time() - start)
assert_that(wait_time).is_between(0, 5)

def test_returns_successfully_when_server_sends_429_and_then_successful_response(self):
client = HttpClient("https://httpbin.seatsio.net", "aSecretKey", None, 5)
client = HttpClient("https://httpbingo.org", "aSecretKey", None, 5)

i = 0
while i < 20:
Expand Down
Loading