Skip to content

Commit 0665cac

Browse files
committed
Merge branch 'task-ucp-3' into task-ucp-4
2 parents d08c46e + 81882c6 commit 0665cac

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

‎checkout_lifecycle_test.py‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,46 @@ def test_cannot_cancel_completed_checkout(self):
413413
msg="Should not be able to cancel a completed checkout.",
414414
)
415415

416+
def test_escalation_flow(self):
417+
"""Test checkout escalation flow.
418+
419+
Given a checkout session,
420+
When completion is attempted with a risk signal triggering escalation,
421+
Then the status should be 'requires_escalation' and continue_url should be
422+
present.
423+
"""
424+
response_json = self.create_checkout_session()
425+
checkout_obj = checkout.Checkout(**response_json)
426+
checkout_id = checkout_obj.id
427+
428+
# Complete with risk signal
429+
payment_payload = integration_test_utils.get_valid_payment_payload()
430+
payment_payload["risk_signals"] = {
431+
"simulation_trigger": "escalation_required"
432+
}
433+
434+
response = self.client.post(
435+
f"/checkout-sessions/{checkout_id}/complete",
436+
json=payment_payload,
437+
headers=integration_test_utils.get_headers(),
438+
)
439+
440+
self.assert_response_status(response, 200)
441+
updated_checkout = checkout.Checkout(**response.json())
442+
443+
self.assertEqual(
444+
updated_checkout.status,
445+
"requires_escalation",
446+
msg="Status should be requires_escalation",
447+
)
448+
self.assertIsNotNone(
449+
updated_checkout.continue_url, "continue_url should be present"
450+
)
451+
self.assertTrue(updated_checkout.messages, "Messages should be present")
452+
self.assertEqual(
453+
updated_checkout.messages[0].root.severity, "requires_buyer_input"
454+
)
455+
416456

417457
if __name__ == "__main__":
418458
absltest.main()

0 commit comments

Comments
 (0)