def test_setexpresscheckout_token_working(self): """ensure setExpressCheckout works as expected when everything goes according to plan""" settings.PAYPAL_OUTCOME = 'PASS' reload(c_settings) # get the api api = PaypalExpressCheckout(checkout=self.checkout) # make the setExpressCheckout call api.setExpressCheckout() # we now have a token self.assertTrue(api.token)
def test_paymentrequestresponse_saving(self): """ensure that every request generates a RequestResponse""" # we have none self.assertEqual(0, RequestResponse.objects.count()) # get the api api = PaypalExpressCheckout(checkout=self.checkout) # make the setExpressCheckout call api.setExpressCheckout() # we have one self.assertEqual(1, RequestResponse.objects.count()) # make the expresscheckout payment api.doExpressCheckout() # we have two self.assertEqual(2, RequestResponse.objects.count())
def test_setexpresscheckout_token_borked(self): """ensure setExpressCheckout works as expected when everything goes according to plan""" # set bork mode & reload settings ORIGINAL_OUTCOME = settings.PAYPAL_OUTCOME settings.PAYPAL_OUTCOME = 'BORK' reload(c_settings) # get the api api = PaypalExpressCheckout(checkout=self.checkout) # make the setExpressCheckout call api.setExpressCheckout() # we now have no token self.assertFalse(api.token) # set it back settings.PAYPAL_OUTCOME = ORIGINAL_OUTCOME reload(c_settings)
def test_setcheckout_with_discount(self): """test the set checkout with discounts""" # add a discount d = DiscountCode() d.type = DiscountCode.PERCENTAGE d.discount = Decimal('50.00') d.code = 'TEST' d.save() self.checkout.discount = d self.checkout.save() # get the api api = PaypalExpressCheckout(checkout=self.checkout) # make the setExpressCheckout call api.setExpressCheckout() # we now have a token self.assertTrue(api.token) # remove the discount self.checkout.discount = None self.checkout.save()