コード例 #1
0
    def test_duplicate_request_id(self):
        credit_card = paypal.CreditCard(self.credit_card_attributes)
        self.assertEqual(credit_card.create(), True)

        new_credit_card = paypal.CreditCard(self.credit_card_attributes)
        new_credit_card.request_id = credit_card.request_id
        self.assertEqual(new_credit_card.create(), True)

        self.assertEqual(new_credit_card.id, credit_card.id)
        self.assertEqual(new_credit_card.request_id, credit_card.request_id)
コード例 #2
0
    def test_duplicate_request_id(self, mock):
        '''
        Test that credit card with identical attributes and request id
        returns the credit card already created. Request id must be the
        same for idempotency
        '''

        response = self.credit_card.create()
        mock.assert_called_once_with(
            self.credit_card.api, 'v1/vault/credit-card',
            self.credit_card_attributes,
            {'PayPal-Request-Id': self.credit_card.request_id}, None)
        self.assertEqual(response, True)

        duplicate_card = paypal.CreditCard(self.credit_card_attributes)
        duplicate_card.request_id = self.credit_card.request_id
        duplicate_card_response = duplicate_card.create()

        mock.assert_called_with(
            self.credit_card.api, 'v1/vault/credit-card',
            self.credit_card_attributes,
            {'PayPal-Request-Id': self.credit_card.request_id}, None)
        self.assertEqual(mock.call_count, 2)
        self.assertEqual(duplicate_card_response, True)
        self.assertEqual(duplicate_card.id, self.credit_card.id)
コード例 #3
0
 def setUp(self):
     self.credit_card_attributes = {
         "type": "visa",
         "number": "4417119669820331",
         "expire_month": "11",
         "expire_year": "2018",
         "cvv2": "874",
         "first_name": "Joe",
         "last_name": "Shopper"
     }
     self.credit_card = paypal.CreditCard(self.credit_card_attributes)
コード例 #4
0
 def test_update(self):
   credit_card = paypal.CreditCard(self.credit_card_attributes)
   first_name = "Billy"
   credit_card_update_attributes = [{
     "op": "replace",
     "path": "/first_name",
     "value": first_name
   }]
   self.assertEqual(credit_card.create(), True)
   self.assertEqual(credit_card.replace(credit_card_update_attributes), True)
   self.assertEqual(credit_card.first_name, first_name)
コード例 #5
0
 def test_delete(self):
     credit_card = paypal.CreditCard(self.credit_card_attributes)
     self.assertEqual(credit_card.create(), True)
     self.assertEqual(credit_card.delete(), True)
コード例 #6
0
  def test_create_and_find(self):
    credit_card = paypal.CreditCard(self.credit_card_attributes)
    self.assertEqual(credit_card.create(), True)

    credit_card = paypal.CreditCard.find(credit_card.id)
    self.assertEqual(credit_card.__class__, paypal.CreditCard)