Skip to content

Commit

Permalink
test(qes): cover document download
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscocastanho-onfido committed Jul 15, 2024
1 parent efecd5f commit 1cbfc74
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ def webhook_clean_up(onfido_api):
def create_applicant(onfido_api, applicant_builder=None):
if applicant_builder is None:
return onfido_api.create_applicant(
onfido.ApplicantBuilder(first_name="First", last_name="Last")
onfido.ApplicantBuilder(
first_name="First",
last_name="Last",
email="first.last@gmail.com",
phone_number="351911111111",
)
)

return onfido_api.create_applicant(applicant_builder)
Expand Down
56 changes: 56 additions & 0 deletions tests/test_qualified_electronic_signatures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import pytest

from onfido import WorkflowRunBuilder

from tests.conftest import (
create_applicant,
create_workflow_run,
)


@pytest.fixture(scope="function")
def applicant_id(onfido_api):
return create_applicant(onfido_api).id


@pytest.fixture(scope="function")
def workflow_id():
return "8b74614f-9e7f-42fd-852a-5f2bcc852587"


@pytest.fixture(scope="function")
def workflow_run(onfido_api, applicant_id, workflow_id):
workflow_run_builder = WorkflowRunBuilder(
applicant_id=applicant_id,
workflow_id=workflow_id,
custom_data={
"country_of_operation": "GBR",
"document_date_of_expiry": "2022-01-01",
"document_issuing_country": "FRA",
"document_issuing_date": "2022-01-01",
"document_number": "Example string",
"document_to_sign_url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
"document_type": "driving_licence",
},
)
return create_workflow_run(
onfido_api, workflow_run_builder=workflow_run_builder
)


@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

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


def test_documents(onfido_api, workflow_run, file_id):
file = onfido_api.download_qes_document(workflow_run.id, file_id)

assert len(file) > 0
assert file[:4] == b"%PDF"

0 comments on commit 1cbfc74

Please sign in to comment.