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
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ jobs:
matrix:
python-version: ['3.10', '3.14']

services:
httpbin:
image: mccutchen/go-httpbin:v2.15.0
Comment thread
mroloux marked this conversation as resolved.
ports:
- 8080:8080

steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v7
Expand All @@ -28,5 +34,6 @@ jobs:
- run: uv run pytest
env:
API_URL: https://api-staging-eu.seatsio.net
HTTPBIN_URL: http://localhost:8080
DEMO_COMPANY_SECRET_KEY: ${{ secrets.DEMO_COMPANY_SECRET_KEY }}
CORE_V2_STAGING_EU_SYSTEM_API_SECRET: ${{ secrets.CORE_V2_STAGING_EU_SYSTEM_API_SECRET }}
4 changes: 4 additions & 0 deletions tests/seatsioClientTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ def wait_for_status_changes(self, event, num_status_changes):
def base_url():
return os.getenv("API_URL") or "http://localhost:9001"

@staticmethod
def httpbin_url():
return os.getenv("HTTPBIN_URL") or "https://httpbingo.org"

@staticmethod
def system_api_secret():
return os.getenv("CORE_V2_STAGING_EU_SYSTEM_API_SECRET") or "superSecretSystemApi"
Expand Down
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://httpbingo.org", "aSecretKey", None, 0, timeout=0.1)
client = HttpClient(self.httpbin_url(), "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://httpbingo.org/delay/1")
assert_that(e.message).is_equal_to("Error while executing GET " + self.httpbin_url() + "/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://httpbingo.org", "aSecretKey", None, 5)
client = HttpClient(self.httpbin_url(), "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://httpbingo.org/status/429")
assert_that(e.message).is_equal_to("Error while executing GET " + self.httpbin_url() + "/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://httpbingo.org", "aSecretKey", None, 5)
client = HttpClient(self.httpbin_url(), "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://httpbingo.org/status/429")
assert_that(e.message).is_equal_to("Error while executing POST " + self.httpbin_url() + "/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://httpbingo.org", "aSecretKey", None, 5)
client = HttpClient(self.httpbin_url(), "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://httpbingo.org/status/429")
assert_that(e.message).is_equal_to("Error while executing DELETE " + self.httpbin_url() + "/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://httpbingo.org", "aSecretKey", None, 5)
client = HttpClient(self.httpbin_url(), "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://httpbingo.org/status/400")
assert_that(e.message).is_equal_to("Error while executing GET " + self.httpbin_url() + "/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://httpbingo.org", "aSecretKey", None, 0)
client = HttpClient(self.httpbin_url(), "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://httpbingo.org/status/429")
assert_that(e.message).is_equal_to("Error while executing GET " + self.httpbin_url() + "/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://httpbingo.org", "aSecretKey", None, 5)
client = HttpClient(self.httpbin_url(), "aSecretKey", None, 5)

i = 0
while i < 20:
Expand Down
Loading