Skip to content

Commit de610dd

Browse files
Merge pull request #79 from onfido/test/fix-evidence-folder-test
test: wait for evidence folder to be available
2 parents 4f882db + ea9987b commit de610dd

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def create_workflow_run(
114114

115115

116116
def repeat_request_until_status_changes(
117-
function, params, status, max_retries=10, sleep_time=1
117+
function, params, status, max_retries=15, sleep_time=1
118118
):
119119
instance = function(*params)
120120

@@ -138,7 +138,7 @@ def repeat_request_until_status_changes(
138138

139139

140140
def repeat_request_until_task_output_changes(
141-
function, params, max_retries=10, sleep_time=1
141+
function, params, max_retries=15, sleep_time=1
142142
):
143143
instance = function(*params)
144144

@@ -156,7 +156,7 @@ def repeat_request_until_task_output_changes(
156156

157157

158158
def repeat_request_until_http_code_changes(
159-
function, params, max_retries=10, sleep_time=1
159+
function, params, max_retries=15, sleep_time=1
160160
):
161161
iteration = 0
162162
while iteration <= max_retries:

tests/test_reports.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import pytest
22

33
from onfido import Report, ReportName, ReportStatus
4-
from tests.conftest import create_applicant, create_check, upload_document
4+
from tests.conftest import (
5+
create_applicant,
6+
create_check,
7+
upload_document,
8+
repeat_request_until_status_changes,
9+
)
510
from typing import List
611

712

@@ -51,13 +56,17 @@ def test_list_reports(sorted_reports):
5156

5257

5358
def test_find_report(onfido_api, document_report_id, identity_report_id):
54-
get_document_report = onfido_api.find_report(document_report_id)
59+
get_document_report = Report(
60+
repeat_request_until_status_changes(
61+
onfido_api.find_report, [document_report_id], ReportStatus.COMPLETE
62+
)
63+
)
5564
get_identity_report = onfido_api.find_report(identity_report_id)
5665

5766
assert isinstance(get_document_report, Report)
5867
assert get_document_report.actual_instance.id == document_report_id
5968
assert get_document_report.actual_instance.name == ReportName.DOCUMENT
60-
assert get_document_report.actual_instance.status == ReportStatus.AWAITING_DATA
69+
assert get_document_report.actual_instance.status == ReportStatus.COMPLETE
6170

6271
assert isinstance(get_identity_report, Report)
6372
assert get_identity_report.actual_instance.id == identity_report_id

tests/test_workflow_runs.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
import zipfile
33
import pytest
44

5-
from onfido import TimelineFileReference, WorkflowRun, WorkflowRunBuilder, WorkflowRunStatus
5+
from onfido import (
6+
TimelineFileReference,
7+
WorkflowRun,
8+
WorkflowRunBuilder,
9+
WorkflowRunStatus,
10+
)
611
from tests.conftest import (
712
create_applicant,
813
create_workflow_run,
@@ -81,7 +86,9 @@ def test_download_evidence_folder(onfido_api, applicant_id):
8186
onfido_api.find_workflow_run, [workflow_run_id], WorkflowRunStatus.APPROVED
8287
)
8388

84-
file = onfido_api.download_evidence_folder(workflow_run_id)
89+
file = repeat_request_until_http_code_changes(
90+
onfido_api.download_evidence_folder, [workflow_run_id]
91+
)
8592

8693
assert len(file) > 0
8794
with tempfile.NamedTemporaryFile() as tmp_file:

0 commit comments

Comments
 (0)