本文整理汇总了Python中paypal.standard.ipn.models.PayPalIPN.delete方法的典型用法代码示例。如果您正苦于以下问题:Python PayPalIPN.delete方法的具体用法?Python PayPalIPN.delete怎么用?Python PayPalIPN.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类paypal.standard.ipn.models.PayPalIPN
的用法示例。
在下文中一共展示了PayPalIPN.delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PaymentTestCase
# 需要导入模块: from paypal.standard.ipn.models import PayPalIPN [as 别名]
# 或者: from paypal.standard.ipn.models.PayPalIPN import delete [as 别名]
class PaymentTestCase(TestCase):
def setUp(self):
self.ipn = PayPalIPN(**DUMMY_IPN)
self.ipn.save()
self.user = User(username="[email protected]", email="[email protected]", password="p")
self.user.save()
self.famille = models.Famille(user=self.user)
self.famille.save()
def tearDown(self):
self.ipn.delete()
self.famille.delete()
self.user.delete()
def test_sign_user_unsign_ok(self):
signed_value = payment.signer.sign_user(self.famille)
value = payment.signer.unsign(signed_value)
expected = "f%s" % self.famille.pk
self.assertEqual(value, expected)
def test_sign_user_unsign_ko(self):
signed_value = payment.signer.sign_user(self.famille)
signed_value = signed_value[:-1]
self.assertRaises(BadSignature, payment.signer.unsign, signed_value)
def test_transaction_is_legit(self):
signed_value = payment.signer.sign_user(self.famille)
self.ipn.invoice = signed_value
self.assertTrue(payment.signer.transaction_is_legit(self.ipn))
def test_transaction_is_legit_wrong_item_number(self):
self.ipn.item_number = "toto"
self.assertFalse(payment.signer.transaction_is_legit(self.ipn))
def test_transation_is_legit_wrong_invoice(self):
self.ipn.invoice = "VDF_f%s:iaozhdazposujazdjqsio" % self.famille.pk
self.assertFalse(payment.signer.transaction_is_legit(self.ipn))
def test_user_from_ipn(self):
self.ipn.invoice = payment.signer.sign_user(self.famille)
f = payment.signer.user_from_ipn(self.ipn)
self.assertEqual(f, self.famille)
def test_user_from_ipn_no_user(self):
famille = models.Famille()
famille.pk = 122
self.ipn.invoice = payment.signer.sign_user(famille)
self.assertRaises(models.Famille.DoesNotExist, payment.signer.user_from_ipn, self.ipn)
def test_user_from_ipn_wrong_signature(self):
self.ipn.invoice = "VDF_f%s:iaozhdazposujazdjqsio" % self.famille.pk
self.assertRaises(BadSignature, payment.signer.user_from_ipn, self.ipn)
def test_premium_signup_ok(self):
self.assertFalse(self.famille.is_premium)
self.ipn.invoice = payment.signer.sign_user(self.famille)
payment.signer.premium_signup(self.ipn)
famille = models.Famille.objects.get(pk=self.famille.pk)
self.assertTrue(famille.is_premium)
expected_expires = datetime.now(utc) + timedelta(days=31)
expected_expires = expected_expires.replace(hour=0, minute=0, second=0, microsecond=0)
self.assertEqual(famille.plan_expires_at, expected_expires)
self.assertEqual(famille.ipn, self.ipn)
def test_compute_expires_at_invalid(self):
self.ipn.item_number = "blah"
self.assertRaises(ValueError, payment.compute_expires_at, self.ipn)
def test_compute_expires_at_presta(self):
self.ipn.item_number = payment.PREMIUM_IDS["12p"]
expires_at = payment.compute_expires_at(self.ipn)
expected = date.today() + timedelta(weeks=52)
self.assertEqual(expires_at, expected)
def test_compute_expires_at_famille(self):
expires_at = payment.compute_expires_at(self.ipn)
expected = date.today() + timedelta(days=31)
self.assertEqual(expires_at, expected)