Skip to content
Open
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1

orbs:
codecov: codecov/codecov@5.0.3
codecov: codecov/codecov@6.0.0

defaults: &defaults
working_directory: ~/project
Expand Down
25 changes: 25 additions & 0 deletions test/unit/testReleasePrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ def get(self, endpoint):

def post(self, endpoint, body):
self.calls.append(("POST", endpoint, body))
if endpoint == "/v1/verifications/trigger":
return {
"ok": True,
"recipientId": body["recipientId"],
"verifications": [
{
"type": body["types"][0],
"status": "created",
"verificationId": "IV-123",
}
],
}
if endpoint.startswith("/v1/batches/"):
return {"ok": True, "batch": {"id": "B-123", "status": "open"}}
if endpoint.startswith("/v1/invoices/payment/create"):
Expand Down Expand Up @@ -105,15 +117,28 @@ def test_verification_gateway_calls_documented_endpoints(self):
expire = gateway.verification.expire({"type": "individual", "verificationIds": ["IV-123"]})
trigger = gateway.verification.trigger("individual", {"recipientIds": ["R-123"]})
watchlist = gateway.verification.trigger_watchlist({"recipientIds": ["R-123"]})
identity = gateway.verification.trigger_identity_or_business_verification({
"recipientId": "R-123",
"types": ["individual"],
"retryAllowed": True,
})

self.assertEqual("WV-123", search[0].id)
self.assertEqual("WV-123", expire[0].id)
self.assertEqual("WV-123", trigger[0].id)
self.assertEqual("WV-123", watchlist[0].id)
self.assertTrue(identity.ok)
self.assertEqual("R-123", identity.recipientId)
self.assertEqual("IV-123", identity.verifications[0].verificationId)
self.assertEqual(("GET", "/v1/verifications?verificationType=watchlist&page=1&pageSize=10", None), fake_client.calls[0])
self.assertEqual(("PATCH", "/v1/verifications/expire", {"type": "individual", "verificationIds": ["IV-123"]}), fake_client.calls[1])
self.assertEqual(("POST", "/v1/verifications/individual/trigger", {"recipientIds": ["R-123"]}), fake_client.calls[2])
self.assertEqual(("POST", "/v1/verifications/watchlist/trigger", {"recipientIds": ["R-123"]}), fake_client.calls[3])
self.assertEqual(("POST", "/v1/verifications/trigger", {
"recipientId": "R-123",
"types": ["individual"],
"retryAllowed": True,
}), fake_client.calls[4])

def test_invoice_payment_create_preserves_existing_body_and_adds_batch_id(self):
gateway = Gateway(Configuration("public", "private"))
Expand Down
27 changes: 27 additions & 0 deletions trolley/verification_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,33 @@ def trigger(self, verification_type, body):
response = trolley.configuration.Configuration.client(self.config).post(endpoint, body)
return self.__build_verifications_from_response(response, True)

def trigger_identity_or_business_verification(self, body):
if body is None:
raise InvalidFieldException("Body cannot be None.")
endpoint = '/v1/verifications/trigger'
response = trolley.configuration.Configuration.client(self.config).post(endpoint, body)
triggered_verification = namedtuple(
"TriggeredVerification",
["type", "status", "verificationId", "error"],
)
verifications = [
triggered_verification(
verification.get('type'),
verification.get('status'),
verification.get('verificationId'),
verification.get('error'),
)
for verification in response.get('verifications', [])
]
return namedtuple(
"IdentityOrBusinessVerificationResult",
["ok", "recipientId", "verifications"],
)(
response.get('ok'),
response.get('recipientId'),
verifications,
)

def trigger_watchlist(self, body):
if body is None:
raise InvalidFieldException("Body cannot be None.")
Expand Down