Skip to content

Commit

Permalink
Extend webhook delivery retrieval timeout in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiltsov-max committed Jan 17, 2025
1 parent f369906 commit 3b34528
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/python/rest_api/test_webhooks_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import json
from http import HTTPStatus
from time import sleep
from time import sleep, time

import pytest
from deepdiff import DeepDiff
Expand Down Expand Up @@ -65,9 +65,11 @@ def create_webhook(events, webhook_type, project_id=None, org_id=""):
return response.json()


def get_deliveries(webhook_id, expected_count=1):
def get_deliveries(webhook_id, expected_count=1, *, timeout: int = 60):
start_time = time()

delivery_response = {}
for _ in range(10):
while True:
response = get_method("admin1", f"webhooks/{webhook_id}/deliveries")
assert response.status_code == HTTPStatus.OK

Expand All @@ -76,6 +78,9 @@ def get_deliveries(webhook_id, expected_count=1):
delivery_response = json.loads(deliveries["results"][0]["response"])
break

if time() - start_time > timeout:
raise TimeoutError("Failed to get deliveries within the specified time interval")

sleep(1)

return deliveries, delivery_response
Expand Down

0 comments on commit 3b34528

Please sign in to comment.