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
15 changes: 15 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,21 @@ def repeat_request_until_task_output_changes(
return instance


def repeat_request_until(function, params, predicate, error_message, max_retries=15, sleep_time=1):
instance = function(*params)

iteration = 0
while not predicate(instance):
if iteration > max_retries:
pytest.fail(error_message)

iteration += 1
sleep(sleep_time)
instance = function(*params)

return instance


def repeat_request_until_http_code_changes(
function, params, max_retries=15, sleep_time=1
):
Expand Down
11 changes: 5 additions & 6 deletions tests/test_biometric_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
BiometricTokenUpdater,
WorkflowRunBuilder,
)
from tests.conftest import create_applicant, repeat_request_until_http_code_changes, upload_live_photo
from tests.conftest import create_applicant, repeat_request_until, upload_live_photo


@pytest.fixture(scope="function")
Expand Down Expand Up @@ -74,17 +74,16 @@ def create_biometric_token(

assert workflow_run.customer_user_id == biometric_customer_user_id

biometric_tokens = repeat_request_until_http_code_changes(
biometric_tokens = repeat_request_until(
onfido_api.list_biometric_tokens,
[biometric_customer_user_id],
lambda response: bool(response.biometric_tokens),
"Biometric tokens were not created in time",
max_retries=10,
sleep_time=3,
)

if biometric_tokens.biometric_tokens:
return biometric_tokens

pytest.fail("Biometric tokens were not created in time")
return biometric_tokens


@pytest.fixture(scope="function")
Expand Down
Loading