Skip to content

Commit 2c3ca3e

Browse files
🧪 enhance job finality check in integration tests for webhook status consistency
1 parent ec7f0a3 commit 2c3ca3e

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

‎tests/v2/test_client_integration.py‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,23 @@ def test_parse_file_filled_single_page_must_succeed(
171171
assert len(supplier_name.locations) == 0
172172

173173

174+
def _job_is_final(job: Job) -> bool:
175+
if job.status == "Failed":
176+
return True
177+
if job.status != "Processed":
178+
return False
179+
# Webhook deliveries happen asynchronously after processing:
180+
# wait until every webhook has reached a final status as well.
181+
return all(webhook.status in {"Completed", "Failed"} for webhook in job.webhooks)
182+
183+
174184
def _enqueue_and_poll_job(v2_client: Client, input_source, params) -> Job:
175-
"""Enqueue a document and poll until the job reaches a final status."""
185+
"""Enqueue a document and poll until the job and its webhooks reach a final status."""
176186
job = v2_client.enqueue(input_source, params).job
177187
for _ in range(60):
178188
sleep(2)
179189
job = v2_client.get_job(job.id).job
180-
if job.status in {"Processed", "Failed"}:
190+
if _job_is_final(job):
181191
break
182192
return job
183193

0 commit comments

Comments
 (0)