當前位置: 首頁>>代碼示例>>Python>>正文


Python Plan.create_add_on方法代碼示例

本文整理匯總了Python中recurly.Plan.create_add_on方法的典型用法代碼示例。如果您正苦於以下問題:Python Plan.create_add_on方法的具體用法?Python Plan.create_add_on怎麽用?Python Plan.create_add_on使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在recurly.Plan的用法示例。


在下文中一共展示了Plan.create_add_on方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_add_on

# 需要導入模塊: from recurly import Plan [as 別名]
# 或者: from recurly.Plan import create_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()
開發者ID:dwoos,項目名稱:recurly-client-python,代碼行數:36,代碼來源:test_resources.py

示例2: test_add_on

# 需要導入模塊: from recurly import Plan [as 別名]
# 或者: from recurly.Plan import create_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()
開發者ID:issuu,項目名稱:recurly-client-python,代碼行數:49,代碼來源:test_resources.py

示例3: test_add_on

# 需要導入模塊: from recurly import Plan [as 別名]
# 或者: from recurly.Plan import create_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/need-amount.xml'):
                try:
                    plan.create_add_on(add_on)
                except ValidationError, exc:
                    pass
                else:
開發者ID:mbeale,項目名稱:recurly-client-python,代碼行數:24,代碼來源:test_resources.py

示例4: test_subscribe_add_on

# 需要導入模塊: from recurly import Plan [as 別名]
# 或者: from recurly.Plan import create_add_on [as 別名]
    def test_subscribe_add_on(self):
        plan = Plan(
            plan_code='basicplan',
            name='Basic Plan',
            setup_fee_in_cents=Money(0),
            unit_amount_in_cents=Money(1000),
        )
        with self.mock_request('subscribe-add-on/plan-created.xml'):
            plan.save()

        try:

            add_on = AddOn(
                add_on_code='mock_add_on',
                name='Mock Add-On',
                unit_amount_in_cents=Money(100),
            )
            with self.mock_request('subscribe-add-on/add-on-created.xml'):
                plan.create_add_on(add_on)

            second_add_on = AddOn(
                add_on_code='second_add_on',
                name='Second Add-On',
                unit_amount_in_cents=Money(50),
            )
            with self.mock_request('subscribe-add-on/second-add-on-created.xml'):
                plan.create_add_on(second_add_on)

            account_code='sad-on-%s' % self.test_id
            sub = Subscription(
                plan_code='basicplan',
                subscription_add_ons=[
                    SubscriptionAddOn(
                        add_on_code='mock_add_on',
                    ),
                    SubscriptionAddOn(
                        add_on_code='second_add_on',
                    ),
                ],
                currency='USD',
                account=Account(
                    account_code=account_code,
                    billing_info=BillingInfo(
                        first_name='Verena',
                        last_name='Example',
                        number='4111 1111 1111 1111',
                        address1='123 Main St',
                        city='San Francisco',
                        state='CA',
                        zip='94105',
                        country='US',
                        verification_value='7777',
                        year='2015',
                        month='12',
                    ),
                ),
            )
            with self.mock_request('subscribe-add-on/subscribed.xml'):
                sub.save()

            # Subscription amounts are in one real currency, so they aren't Money instances.
            sub_amount = sub.unit_amount_in_cents
            self.assertTrue(not isinstance(sub_amount, Money))
            self.assertEqual(sub_amount, 1000)

            # Test that the add-ons' amounts aren't real Money instances either.
            add_on_1, add_on_2 = sub.subscription_add_ons
            self.assertIsInstance(add_on_1, SubscriptionAddOn)
            amount_1 = add_on_1.unit_amount_in_cents
            self.assertTrue(not isinstance(amount_1, Money))
            self.assertEqual(amount_1, 100)

            with self.mock_request('subscribe-add-on/account-exists.xml'):
                account = Account.get(account_code)
            with self.mock_request('subscribe-add-on/account-deleted.xml'):
                account.delete()

        finally:
            with self.mock_request('subscribe-add-on/plan-deleted.xml'):
                plan.delete()
開發者ID:mbeale,項目名稱:recurly-client-python,代碼行數:82,代碼來源:test_resources.py

示例5: test_subscribe_add_on

# 需要導入模塊: from recurly import Plan [as 別名]
# 或者: from recurly.Plan import create_add_on [as 別名]
    def test_subscribe_add_on(self):
        plan = Plan(
            plan_code="basicplan", name="Basic Plan", setup_fee_in_cents=Money(0), unit_amount_in_cents=Money(1000)
        )
        with self.mock_request("subscribe-add-on/plan-created.xml"):
            plan.save()

        try:

            add_on = AddOn(add_on_code="mock_add_on", name="Mock Add-On", unit_amount_in_cents=Money(100))
            with self.mock_request("subscribe-add-on/add-on-created.xml"):
                plan.create_add_on(add_on)

            second_add_on = AddOn(add_on_code="second_add_on", name="Second Add-On", unit_amount_in_cents=Money(50))
            with self.mock_request("subscribe-add-on/second-add-on-created.xml"):
                plan.create_add_on(second_add_on)

            account_code = "sad-on-%s" % self.test_id
            sub = Subscription(
                plan_code="basicplan",
                subscription_add_ons=[
                    SubscriptionAddOn(add_on_code="mock_add_on"),
                    SubscriptionAddOn(add_on_code="second_add_on"),
                ],
                currency="USD",
                account=Account(
                    account_code=account_code,
                    billing_info=BillingInfo(
                        first_name="Verena",
                        last_name="Example",
                        number="4111 1111 1111 1111",
                        address1="123 Main St",
                        city="San Francisco",
                        state="CA",
                        zip="94105",
                        country="US",
                        verification_value="7777",
                        year="2015",
                        month="12",
                    ),
                ),
            )
            with self.mock_request("subscribe-add-on/subscribed.xml"):
                sub.save()

            # Subscription amounts are in one real currency, so they aren't Money instances.
            sub_amount = sub.unit_amount_in_cents
            self.assertTrue(not isinstance(sub_amount, Money))
            self.assertEqual(sub_amount, 1000)

            # Test that the add-ons' amounts aren't real Money instances either.
            add_on_1, add_on_2 = sub.subscription_add_ons
            self.assertIsInstance(add_on_1, SubscriptionAddOn)
            amount_1 = add_on_1.unit_amount_in_cents
            self.assertTrue(not isinstance(amount_1, Money))
            self.assertEqual(amount_1, 100)

            with self.mock_request("subscribe-add-on/account-exists.xml"):
                account = Account.get(account_code)
            with self.mock_request("subscribe-add-on/account-deleted.xml"):
                account.delete()

        finally:
            with self.mock_request("subscribe-add-on/plan-deleted.xml"):
                plan.delete()
開發者ID:tbartelmess,項目名稱:recurly-client-python,代碼行數:67,代碼來源:test_resources.py

示例6: test_subscribe_add_on

# 需要導入模塊: from recurly import Plan [as 別名]
# 或者: from recurly.Plan import create_add_on [as 別名]
    def test_subscribe_add_on(self):
        plan = Plan(
            plan_code='basicplan',
            name='Basic Plan',
            setup_fee_in_cents=Money(0),
            unit_amount_in_cents=Money(1000),
        )
        with self.mock_request('subscribe-add-on/plan-created.xml'):
            plan.save()

        try:

            add_on = AddOn(
                add_on_code='mock_add_on',
                name='Mock Add-On',
                unit_amount_in_cents=Money(100),
            )
            with self.mock_request('subscribe-add-on/add-on-created.xml'):
                plan.create_add_on(add_on)

            second_add_on = AddOn(
                add_on_code='second_add_on',
                name='Second Add-On',
                unit_amount_in_cents=Money(50),
            )
            with self.mock_request('subscribe-add-on/second-add-on-created.xml'):
                plan.create_add_on(second_add_on)

            account_code='sad-on-%s' % self.test_id
            sub = Subscription(
                plan_code='basicplan',
                subscription_add_ons=[
                    SubscriptionAddOn(
                        add_on_code='mock_add_on',
                    ),
                    SubscriptionAddOn(
                        add_on_code='second_add_on',
                    ),
                ],
                currency='USD',
                account=Account(
                    account_code=account_code,
                    billing_info=BillingInfo(
                        first_name='Verena',
                        last_name='Example',
                        number='4111 1111 1111 1111',
                        verification_value='7777',
                        year='2015',
                        month='12',
                    ),
                ),
            )
            with self.mock_request('subscribe-add-on/subscribed.xml'):
                sub.save()

            with self.mock_request('subscribe-add-on/account-exists.xml'):
                account = Account.get(account_code)
            with self.mock_request('subscribe-add-on/account-deleted.xml'):
                account.delete()

        finally:
            with self.mock_request('subscribe-add-on/plan-deleted.xml'):
                plan.delete()
開發者ID:dwoos,項目名稱:recurly-client-python,代碼行數:65,代碼來源:test_resources.py


注:本文中的recurly.Plan.create_add_on方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。