From 369bd08818c1c44b3c62243200aa00be38203664 Mon Sep 17 00:00:00 2001 From: Andrey Eremin Date: Mon, 31 Aug 2026 15:22:19 +0200 Subject: [PATCH 1/2] SIG-4322: Add tests for watchlists mesh endpoint --- tests/test_watchlist_alert_risks.py | 97 +++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 tests/test_watchlist_alert_risks.py diff --git a/tests/test_watchlist_alert_risks.py b/tests/test_watchlist_alert_risks.py new file mode 100644 index 0000000..a678862 --- /dev/null +++ b/tests/test_watchlist_alert_risks.py @@ -0,0 +1,97 @@ +from datetime import date +from uuid import UUID + +import pytest + +from onfido import ( + AddressBuilder, + ApplicantBuilder, + WatchlistAlertRisk, + WorkflowRunBuilder, +) +from tests.conftest import ( + create_applicant, + repeat_request_until_task_output_changes, +) + + +@pytest.fixture(scope="function") +def applicant_id(onfido_api): + applicant = create_applicant( + onfido_api, + ApplicantBuilder( + first_name="Donald", + last_name="Consider", + dob=date(1990, 1, 1), + address=AddressBuilder( + country="PRT", + town="Town", + street="Street", + building_number="12", + postcode="12345", + ), + ), + ) + return applicant.id + + +@pytest.fixture(scope="function") +def workflow_id(): + return UUID("18effbfe-73c3-4680-ae43-e1c474767ff4") + + +@pytest.fixture(scope="function") +def workflow_run(onfido_api, applicant_id, workflow_id): + return onfido_api.create_workflow_run( + WorkflowRunBuilder( + applicant_id=applicant_id, + workflow_id=workflow_id, + custom_data={ + "national_id": { + "type": "passport", + "value": "P1234567", + }, + "nationality": "PRT", + }, + ) + ) + + +@pytest.fixture(scope="function") +def watchlist_task(onfido_api, workflow_run): + task = next( + ( + workflow_task + for workflow_task in onfido_api.list_tasks(workflow_run.id) + if workflow_task.task_def_id == "query_watchlists_complyadvantage_mesh" + ), + None, + ) + + assert task is not None + + return repeat_request_until_task_output_changes( + onfido_api.find_task, + [workflow_run.id, task.id], + max_retries=30, + sleep_time=2, + ) + + +@pytest.fixture(scope="function") +def alert_id(watchlist_task): + alert_identifier = watchlist_task.output["properties"]["alert_identifier"] + + assert alert_identifier is not None + return UUID(alert_identifier) + + +def test_list_watchlist_alert_risks(onfido_api, alert_id): + risks = onfido_api.list_watchlist_alert_risks(alert_id, page=1, per_page=1) + + assert len(risks) > 0 + assert len(risks) <= 1 + assert isinstance(risks[0], WatchlistAlertRisk) + assert risks[0].identifier is not None + assert risks[0].decision is not None + assert risks[0].detail is not None From 1ae55464121ca70b8dfc9261a12ed5c77f112f14 Mon Sep 17 00:00:00 2001 From: Andrey Eremin Date: Mon, 31 Aug 2026 17:46:34 +0200 Subject: [PATCH 2/2] Fix tests --- tests/test_watchlist_alert_risks.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test_watchlist_alert_risks.py b/tests/test_watchlist_alert_risks.py index a678862..41eccb9 100644 --- a/tests/test_watchlist_alert_risks.py +++ b/tests/test_watchlist_alert_risks.py @@ -6,7 +6,7 @@ from onfido import ( AddressBuilder, ApplicantBuilder, - WatchlistAlertRisk, + WatchlistMeshAlertRisk, WorkflowRunBuilder, ) from tests.conftest import ( @@ -87,11 +87,13 @@ def alert_id(watchlist_task): def test_list_watchlist_alert_risks(onfido_api, alert_id): - risks = onfido_api.list_watchlist_alert_risks(alert_id, page=1, per_page=1) + risks = onfido_api.list_watchlist_mesh_alert_risks( + alert_id, page=1, per_page=1 + ) assert len(risks) > 0 assert len(risks) <= 1 - assert isinstance(risks[0], WatchlistAlertRisk) + assert isinstance(risks[0], WatchlistMeshAlertRisk) assert risks[0].identifier is not None assert risks[0].decision is not None assert risks[0].detail is not None