Skip to content

Commit

Permalink
Fix and improve tests after library refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
dvacca-onfido committed Oct 18, 2024
1 parent 5a4d20a commit 168d1dd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def create_applicant(onfido_api, applicant_builder=None):
def upload_document(onfido_api, applicant_id):
return onfido_api.upload_document(
applicant_id=applicant_id,
type="passport",
type=onfido.DocumentTypes.PASSPORT,
side="front",
file="tests/media/sample_driving_licence.png",
)
Expand Down Expand Up @@ -142,13 +142,13 @@ def repeat_request_until_task_output_changes(
instance = function(*params)

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

iteration += 1
sleep(sleep_time)

instance = function(*params)

return instance
Expand Down
4 changes: 2 additions & 2 deletions tests/test_documents.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from onfido import ApiException, Document, DocumentsList
from onfido import ApiException, Document, DocumentsList, DocumentTypes
from tests.conftest import create_applicant, upload_document


Expand All @@ -17,7 +17,7 @@ def document(onfido_api, applicant_id):
def test_create_document(applicant_id, document):
assert document is not None
assert document.applicant_id == applicant_id
assert document.type == "passport"
assert document.type == DocumentTypes.PASSPORT
assert document.side == "front"
assert isinstance(document, Document)

Expand Down
3 changes: 1 addition & 2 deletions tests/test_qualified_electronic_signatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ def workflow_run(onfido_api, applicant_id, workflow_id):

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

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

output = repeat_request_until_task_output_changes(
onfido_api.find_task, [workflow_run.id, task.id], max_retries=10, sleep_time=3
Expand Down
11 changes: 7 additions & 4 deletions tests/test_webhook_verification.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from onfido.webhook_event_verifier import WebhookEventVerifier, OnfidoInvalidSignatureError
from onfido import WebhookEvent, WebhookEventPayload, WebhookEventPayloadObject
from onfido import (
WebhookEvent, WebhookEventPayload, WebhookEventPayloadObject,
WebhookEventResourceType, WebhookEventType, WebhookEventObjectStatus
)

import pytest

Expand All @@ -12,12 +15,12 @@

expected_event = WebhookEvent(
payload=WebhookEventPayload(
action="check.completed",
resource_type="check",
action=WebhookEventType.CHECK_DOT_COMPLETED,
resource_type=WebhookEventResourceType.CHECK,
object=WebhookEventPayloadObject(
id='f2302f45-227d-413d-ad61-09ec077a086a',
href='https://api.onfido.com/v3.6/checks/f2302f45-227d-413d-ad61-09ec077a086a',
status="complete",
status=WebhookEventObjectStatus.COMPLETE,
completed_at_iso8601='2024-04-04T09:21:21Z'
)
)
Expand Down

0 comments on commit 168d1dd

Please sign in to comment.