当前位置: 首页>>代码示例>>Python>>正文


Python Account.billing_info方法代码示例

本文整理汇总了Python中recurly.Account.billing_info方法的典型用法代码示例。如果您正苦于以下问题:Python Account.billing_info方法的具体用法?Python Account.billing_info怎么用?Python Account.billing_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在recurly.Account的用法示例。


在下文中一共展示了Account.billing_info方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_billing_info

# 需要导入模块: from recurly import Account [as 别名]
# 或者: from recurly.Account import billing_info [as 别名]
    def test_billing_info(self):
        logging.basicConfig(level=logging.DEBUG)  # make sure it's init'ed
        logger = logging.getLogger('recurly.http.request')
        logger.setLevel(logging.DEBUG)

        log_content = StringIO()
        log_handler = logging.StreamHandler(log_content)
        logger.addHandler(log_handler)

        account = Account(account_code='binfo%s' % self.test_id)
        with self.mock_request('billing-info/account-created.xml'):
            account.save()

        logger.removeHandler(log_handler)
        self.assertTrue('<account' in log_content.getvalue())

        try:

            # Billing info link won't be present at all yet.
            self.assertRaises(AttributeError, getattr, account, 'billing_info')

            log_content = StringIO()
            log_handler = logging.StreamHandler(log_content)
            logger.addHandler(log_handler)

            binfo = BillingInfo(
                first_name='Verena',
                last_name='Example',
                address1='123 Main St',
                city=u'San Jos\xe9',
                state='CA',
                zip='94105',
                country='US',
                type='credit_card',
                number='4111 1111 1111 1111',
                verification_value='7777',
                year='2015',
                month='12',
            )
            with self.mock_request('billing-info/created.xml'):
                account.update_billing_info(binfo)

            logger.removeHandler(log_handler)
            log_content = log_content.getvalue()
            self.assertTrue('<billing_info' in log_content)
            # See if we redacted our sensitive fields properly.
            self.assertTrue('4111' not in log_content)
            self.assertTrue('7777' not in log_content)

            with self.mock_request('billing-info/account-exists.xml'):
                same_account = Account.get('binfo%s' % self.test_id)
            with self.mock_request('billing-info/exists.xml'):
                same_binfo = same_account.billing_info
            self.assertEqual(same_binfo.first_name, 'Verena')
            self.assertEqual(same_binfo.city, u'San Jos\xe9')

            with self.mock_request('billing-info/deleted.xml'):
                binfo.delete()
        finally:
            with self.mock_request('billing-info/account-deleted.xml'):
                account.delete()

        log_content = StringIO()
        log_handler = logging.StreamHandler(log_content)
        logger.addHandler(log_handler)

        account = Account(account_code='binfo-%s-2' % self.test_id)
        account.billing_info = BillingInfo(
            first_name='Verena',
            last_name='Example',
            address1='123 Main St',
            city=u'San Jos\xe9',
            state='CA',
            zip='94105',
            country='US',
            type='credit_card',
            number='4111 1111 1111 1111',
            verification_value='7777',
            year='2015',
            month='12',
        )
        with self.mock_request('billing-info/account-embed-created.xml'):
            account.save()

        try:
            logger.removeHandler(log_handler)
            log_content = log_content.getvalue()
            self.assertTrue('<account' in log_content)
            self.assertTrue('<billing_info' in log_content)
            self.assertTrue('4111' not in log_content)
            self.assertTrue('7777' not in log_content)

            with self.mock_request('billing-info/account-embed-exists.xml'):
                same_account = Account.get('binfo-%s-2' % self.test_id)
            with self.mock_request('billing-info/embedded-exists.xml'):
                binfo = same_account.billing_info
            self.assertEqual(binfo.first_name, 'Verena')
        finally:
            with self.mock_request('billing-info/account-embed-deleted.xml'):
                account.delete()
开发者ID:mbeale,项目名称:recurly-client-python,代码行数:102,代码来源:test_resources.py

示例2: test_billing_info

# 需要导入模块: from recurly import Account [as 别名]
# 或者: from recurly.Account import billing_info [as 别名]
    def test_billing_info(self):
        logging.basicConfig(level=logging.DEBUG)  # make sure it's init'ed
        logger = logging.getLogger("recurly.http.request")
        logger.setLevel(logging.DEBUG)

        log_content = StringIO()
        log_handler = logging.StreamHandler(log_content)
        logger.addHandler(log_handler)

        account = Account(account_code="binfo%s" % self.test_id)
        with self.mock_request("billing-info/account-created.xml"):
            account.save()

        logger.removeHandler(log_handler)
        self.assertTrue("<account" in log_content.getvalue())

        try:

            # Billing info link won't be present at all yet.
            self.assertRaises(AttributeError, getattr, account, "billing_info")

            log_content = StringIO()
            log_handler = logging.StreamHandler(log_content)
            logger.addHandler(log_handler)

            binfo = BillingInfo(
                first_name="Verena",
                last_name="Example",
                address1="123 Main St",
                city=six.u("San Jos\xe9"),
                state="CA",
                zip="94105",
                country="US",
                type="credit_card",
                number="4111 1111 1111 1111",
                verification_value="7777",
                year="2015",
                month="12",
            )
            with self.mock_request("billing-info/created.xml"):
                account.update_billing_info(binfo)

            logger.removeHandler(log_handler)
            log_content = log_content.getvalue()
            self.assertTrue("<billing_info" in log_content)
            # See if we redacted our sensitive fields properly.
            self.assertTrue("4111" not in log_content)
            self.assertTrue("7777" not in log_content)

            with self.mock_request("billing-info/account-exists.xml"):
                same_account = Account.get("binfo%s" % self.test_id)
            with self.mock_request("billing-info/exists.xml"):
                same_binfo = same_account.billing_info
            self.assertEqual(same_binfo.first_name, "Verena")
            self.assertEqual(same_binfo.city, six.u("San Jos\xe9"))

            with self.mock_request("billing-info/deleted.xml"):
                binfo.delete()
        finally:
            with self.mock_request("billing-info/account-deleted.xml"):
                account.delete()

        # Credit Card
        log_content = StringIO()
        log_handler = logging.StreamHandler(log_content)
        logger.addHandler(log_handler)

        account = Account(account_code="binfo-%s-2" % self.test_id)
        account.billing_info = BillingInfo(
            first_name="Verena",
            last_name="Example",
            address1="123 Main St",
            city=six.u("San Jos\xe9"),
            state="CA",
            zip="94105",
            country="US",
            type="credit_card",
            number="4111 1111 1111 1111",
            verification_value="7777",
            year="2015",
            month="12",
        )
        with self.mock_request("billing-info/account-embed-created.xml"):
            account.save()

        try:
            logger.removeHandler(log_handler)
            log_content = log_content.getvalue()
            self.assertTrue("<account" in log_content)
            self.assertTrue("<billing_info" in log_content)
            self.assertTrue("4111" not in log_content)
            self.assertTrue("7777" not in log_content)

            with self.mock_request("billing-info/account-embed-exists.xml"):
                same_account = Account.get("binfo-%s-2" % self.test_id)
            with self.mock_request("billing-info/embedded-exists.xml"):
                binfo = same_account.billing_info
            self.assertEqual(binfo.first_name, "Verena")
        finally:
            with self.mock_request("billing-info/account-embed-deleted.xml"):
#.........这里部分代码省略.........
开发者ID:tbartelmess,项目名称:recurly-client-python,代码行数:103,代码来源:test_resources.py


注:本文中的recurly.Account.billing_info方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。