Skip to content

Commit

Permalink
test(qes): wait until output changes
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscocastanho-onfido committed Jul 15, 2024
1 parent 1cbfc74 commit 87adbfc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
18 changes: 18 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,24 @@ def repeat_request_until_status_changes(
return instance


def repeat_request_until_task_output_changes(
function, params, max_retries=10, sleep_time=1
):
instance = function(*params)

iteration = 0
while instance.output == None:
if iteration > max_retries:
pytest.fail("Task output did not change in time")

iteration += 1
sleep(sleep_time)

instance = function(*params)

return instance


def repeat_request_until_http_code_changes(
function, params, max_retries=10, sleep_time=1
):
Expand Down
8 changes: 5 additions & 3 deletions tests/test_qualified_electronic_signatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from tests.conftest import (
create_applicant,
create_workflow_run,
repeat_request_until_task_output_changes,
)


Expand Down Expand Up @@ -40,11 +41,12 @@ def workflow_run(onfido_api, applicant_id, workflow_id):

@pytest.fixture(scope="function")
def file_id(onfido_api, workflow_run):
import time
time.sleep(2)

task = onfido_api.list_tasks(workflow_run.id)[0]

output = onfido_api.find_task(workflow_run.id, task.id).output
output = repeat_request_until_task_output_changes(
onfido_api.find_task, [workflow_run.id, task.id], max_retries=10, sleep_time=3
).output

return output["properties"]["signed_documents"][0]["id"]

Expand Down

0 comments on commit 87adbfc

Please sign in to comment.