Permalink
Browse files

Add exception handling unit test to direct payment test suite. Really…

… important that users get a proper exception thrown so they are aware of failures in validation or processing.
  • Loading branch information...
1 parent ca60187 commit 7066469baec73c1fe660c70176072096e6acce24 @gtaylor gtaylor committed with Aug 9, 2010
Showing with 13 additions and 0 deletions.
  1. +13 −0 tests/t_direct_payment.py
View
13 tests/t_direct_payment.py
@@ -1,6 +1,7 @@
# coding=utf-8
import unittest
+from paypal import PayPalAPIResponseError
import interface_factory
import api_details
@@ -32,6 +33,18 @@ def test_sale(self):
self.assertTrue(details.success)
self.assertEqual(details.PAYMENTSTATUS.upper(), 'COMPLETED')
self.assertEqual(details.REASONCODE.upper(), 'NONE')
+
+ def test_exception_handling(self):
+ """
+ Make sure response exception handling is working as intended by
+ forcing some bad values.
+ """
+ new_details = self.credit_card
+ # Set an invalid credit card number.
+ new_details['acct'] = '123'
+ # Make sure this raises an exception.
+ self.assertRaises(PayPalAPIResponseError, interface.do_direct_payment,
+ 'Sale', **new_details)
def test_abbreviated_sale(self):
sale = interface.do_direct_payment(**self.credit_card)

0 comments on commit 7066469

Please sign in to comment.