コード例 #1
0
 def test_returns_approved_transaction(self):
     with mock.patch('paypal.payflow.gateway.sale') as mock_f:
         mock_f.return_value = models.PayflowTransaction(
             result='0'
         )
         txn = self.sale()
         self.assertTrue(txn.is_approved)
コード例 #2
0
 def test_raises_exception_when_not_approved(self):
     with mock.patch('paypal.payflow.gateway.authorize') as mock_f:
         mock_f.return_value = models.PayflowTransaction(
             result='1'
         )
         with self.assertRaises(exceptions.UnableToTakePayment):
             self.authorize()
コード例 #3
0
 def test_returns_nothing_when_txn_is_approved(self):
     models.PayflowTransaction.objects.create(
         trxtype=codes.AUTHORIZATION,
         comment1='1234',
         pnref='V19A3A079142',
         response_time=0,
     )
     with mock.patch('paypal.payflow.gateway.delayed_capture') as mock_f:
         mock_f.return_value = models.PayflowTransaction(result='0')
         facade.delayed_capture('1234')
コード例 #4
0
 def test_not_approved_exception_contains_useful_message(self):
     with mock.patch('paypal.payflow.gateway.authorize') as mock_f:
         mock_f.return_value = models.PayflowTransaction(
             result='23',
             respmsg='Invalid account number',
         )
         try:
             self.authorize()
         except exceptions.UnableToTakePayment as e:
             self.assertEqual("Invalid account number", six.text_type(e))