本文整理匯總了Python中recurly.Plan.get_add_on方法的典型用法代碼示例。如果您正苦於以下問題:Python Plan.get_add_on方法的具體用法?Python Plan.get_add_on怎麽用?Python Plan.get_add_on使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類recurly.Plan
的用法示例。
在下文中一共展示了Plan.get_add_on方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_add_on
# 需要導入模塊: from recurly import Plan [as 別名]
# 或者: from recurly.Plan import get_add_on [as 別名]
def test_add_on(self):
plan_code = 'plan%s' % self.test_id
add_on_code = 'addon%s' % self.test_id
plan = Plan(
plan_code=plan_code,
name='Mock Plan',
setup_fee_in_cents=Money(0),
unit_amount_in_cents=Money(1000),
)
with self.mock_request('add-on/plan-created.xml'):
plan.save()
try:
add_on = AddOn(add_on_code=add_on_code, name='Mock Add-On')
with self.mock_request('add-on/created.xml'):
plan.create_add_on(add_on)
self.assertEqual(add_on.add_on_code, add_on_code)
self.assertEqual(add_on.name, 'Mock Add-On')
try:
with self.mock_request('add-on/exists.xml'):
same_add_on = plan.get_add_on(add_on_code)
self.assertEqual(same_add_on.add_on_code, add_on_code)
self.assertEqual(same_add_on.name, 'Mock Add-On')
finally:
with self.mock_request('add-on/deleted.xml'):
add_on.delete()
finally:
with self.mock_request('add-on/plan-deleted.xml'):
plan.delete()
示例2: test_add_on
# 需要導入模塊: from recurly import Plan [as 別名]
# 或者: from recurly.Plan import get_add_on [as 別名]
def test_add_on(self):
plan_code = 'plan%s' % self.test_id
add_on_code = 'addon%s' % self.test_id
plan = Plan(
plan_code=plan_code,
name='Mock Plan',
setup_fee_in_cents=Money(0),
unit_amount_in_cents=Money(1000),
)
with self.mock_request('add-on/plan-created.xml'):
plan.save()
try:
add_on = AddOn(add_on_code=add_on_code, name='Mock Add-On')
exc = None
with self.mock_request('add-on/need-amount.xml'):
try:
plan.create_add_on(add_on)
except ValidationError as _exc:
exc = _exc
else:
self.fail("Creating a plan add-on without an amount did not raise a ValidationError")
error = exc.errors['add_on.unit_amount_in_cents']
self.assertEqual(error.symbol, 'blank')
add_on = AddOn(add_on_code=add_on_code, name='Mock Add-On', unit_amount_in_cents=Money(40))
with self.mock_request('add-on/created.xml'):
plan.create_add_on(add_on)
self.assertEqual(add_on.add_on_code, add_on_code)
self.assertEqual(add_on.name, 'Mock Add-On')
try:
with self.mock_request('add-on/exists.xml'):
same_add_on = plan.get_add_on(add_on_code)
self.assertEqual(same_add_on.add_on_code, add_on_code)
self.assertEqual(same_add_on.name, 'Mock Add-On')
self.assertEqual(same_add_on.unit_amount_in_cents['USD'], 40)
finally:
with self.mock_request('add-on/deleted.xml'):
add_on.delete()
finally:
with self.mock_request('add-on/plan-deleted.xml'):
plan.delete()