本文整理汇总了Python中recurly.Account.vat_number方法的典型用法代码示例。如果您正苦于以下问题:Python Account.vat_number方法的具体用法?Python Account.vat_number怎么用?Python Account.vat_number使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类recurly.Account
的用法示例。
在下文中一共展示了Account.vat_number方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_account
# 需要导入模块: from recurly import Account [as 别名]
# 或者: from recurly.Account import vat_number [as 别名]
def test_account(self):
account_code = 'test%s' % self.test_id
with self.mock_request('account/does-not-exist.xml'):
self.assertRaises(NotFoundError, Account.get, account_code)
account = Account(account_code=account_code)
account.vat_number = '444444-UK'
with self.mock_request('account/created.xml'):
account.save()
self.assertEqual(account._url, urljoin(recurly.base_uri(), 'accounts/%s' % account_code))
self.assertEqual(account.vat_number, '444444-UK')
with self.mock_request('account/list-active.xml'):
active = Account.all_active()
self.assertTrue(len(active) >= 1)
self.assertEqual(active[0].account_code, account_code)
with self.mock_request('account/exists.xml'):
same_account = Account.get(account_code)
self.assertTrue(isinstance(same_account, Account))
self.assertTrue(same_account is not account)
self.assertEqual(same_account.account_code, account_code)
self.assertTrue(same_account.first_name is None)
self.assertTrue(same_account.entity_use_code == 'I')
self.assertEqual(same_account._url, urljoin(recurly.base_uri(), 'accounts/%s' % account_code))
account.username = 'shmohawk58'
account.email = 'larry.david'
account.first_name = six.u('L\xe4rry')
account.last_name = 'David'
account.company_name = 'Home Box Office'
account.accept_language = 'en-US'
with self.mock_request('account/update-bad-email.xml'):
try:
account.save()
except ValidationError as exc:
self.assertTrue(isinstance(exc.errors, collections.Mapping))
self.assertTrue('account.email' in exc.errors)
suberror = exc.errors['account.email']
self.assertEqual(suberror.symbol, 'invalid_email')
self.assertTrue(suberror.message)
self.assertEqual(suberror.message, suberror.message)
else:
self.fail("Updating account with invalid email address did not raise a ValidationError")
account.email = '[email protected]'
with self.mock_request('account/updated.xml'):
account.save()
with self.mock_request('account/deleted.xml'):
account.delete()
with self.mock_request('account/list-closed.xml'):
closed = Account.all_closed()
self.assertTrue(len(closed) >= 1)
self.assertEqual(closed[0].account_code, account_code)
with self.mock_request('account/list-active-when-closed.xml'):
active = Account.all_active()
self.assertTrue(len(active) < 1 or active[0].account_code != account_code)
# Make sure we can reopen a closed account.
with self.mock_request('account/reopened.xml'):
account.reopen()
try:
with self.mock_request('account/list-active.xml'):
active = Account.all_active()
self.assertTrue(len(active) >= 1)
self.assertEqual(active[0].account_code, account_code)
finally:
with self.mock_request('account/deleted.xml'):
account.delete()
# Make sure numeric account codes work.
if self.test_id == 'mock':
numeric_test_id = 58
else:
numeric_test_id = int(self.test_id)
account = Account(account_code=numeric_test_id)
with self.mock_request('account/numeric-created.xml'):
account.save()
try:
self.assertEqual(account._url, urljoin(recurly.base_uri(), 'accounts/%d' % numeric_test_id))
finally:
with self.mock_request('account/numeric-deleted.xml'):
account.delete()
"""Create an account with an account level address"""
account = Account(account_code=account_code)
account.address.address1 = '123 Main St'
account.address.city = 'San Francisco'
account.address.zip = '94105'
account.address.state = 'CA'
account.address.country = 'US'
account.address.phone = '8015559876'
with self.mock_request('account/created-with-address.xml'):
account.save()
self.assertEqual(account.address.address1, '123 Main St')
self.assertEqual(account.address.city, 'San Francisco')
#.........这里部分代码省略.........
示例2: test_account
# 需要导入模块: from recurly import Account [as 别名]
# 或者: from recurly.Account import vat_number [as 别名]
def test_account(self):
account_code = "test%s" % self.test_id
with self.mock_request("account/does-not-exist.xml"):
self.assertRaises(NotFoundError, Account.get, account_code)
account = Account(account_code=account_code)
account.vat_number = "444444-UK"
with self.mock_request("account/created.xml"):
account.save()
self.assertEqual(account._url, urljoin(recurly.base_uri(), "accounts/%s" % account_code))
self.assertEqual(account.vat_number, "444444-UK")
self.assertEqual(account.vat_location_enabled, True)
with self.mock_request("account/list-active.xml"):
active = Account.all_active()
self.assertTrue(len(active) >= 1)
self.assertEqual(active[0].account_code, account_code)
with self.mock_request("account/exists.xml"):
same_account = Account.get(account_code)
self.assertTrue(isinstance(same_account, Account))
self.assertTrue(same_account is not account)
self.assertEqual(same_account.account_code, account_code)
self.assertTrue(same_account.first_name is None)
self.assertTrue(same_account.entity_use_code == "I")
self.assertEqual(same_account._url, urljoin(recurly.base_uri(), "accounts/%s" % account_code))
account.username = "shmohawk58"
account.email = "larry.david"
account.first_name = six.u("L\xe4rry")
account.last_name = "David"
account.company_name = "Home Box Office"
account.accept_language = "en-US"
with self.mock_request("account/update-bad-email.xml"):
try:
account.save()
except ValidationError as exc:
self.assertTrue(isinstance(exc.errors, collections.Mapping))
self.assertTrue("account.email" in exc.errors)
suberror = exc.errors["account.email"]
self.assertEqual(suberror.symbol, "invalid_email")
self.assertTrue(suberror.message)
self.assertEqual(suberror.message, suberror.message)
else:
self.fail("Updating account with invalid email address did not raise a ValidationError")
account.email = "[email protected]"
with self.mock_request("account/updated.xml"):
account.save()
with self.mock_request("account/deleted.xml"):
account.delete()
with self.mock_request("account/list-closed.xml"):
closed = Account.all_closed()
self.assertTrue(len(closed) >= 1)
self.assertEqual(closed[0].account_code, account_code)
with self.mock_request("account/list-active-when-closed.xml"):
active = Account.all_active()
self.assertTrue(len(active) < 1 or active[0].account_code != account_code)
# Make sure we can reopen a closed account.
with self.mock_request("account/reopened.xml"):
account.reopen()
try:
with self.mock_request("account/list-active.xml"):
active = Account.all_active()
self.assertTrue(len(active) >= 1)
self.assertEqual(active[0].account_code, account_code)
finally:
with self.mock_request("account/deleted.xml"):
account.delete()
# Make sure numeric account codes work.
if self.test_id == "mock":
numeric_test_id = 58
else:
numeric_test_id = int(self.test_id)
account = Account(account_code=numeric_test_id)
with self.mock_request("account/numeric-created.xml"):
account.save()
try:
self.assertEqual(account._url, urljoin(recurly.base_uri(), "accounts/%d" % numeric_test_id))
finally:
with self.mock_request("account/numeric-deleted.xml"):
account.delete()
"""Create an account with an account level address"""
account = Account(account_code=account_code)
account.address.address1 = "123 Main St"
account.address.city = "San Francisco"
account.address.zip = "94105"
account.address.state = "CA"
account.address.country = "US"
account.address.phone = "8015559876"
with self.mock_request("account/created-with-address.xml"):
account.save()
self.assertEqual(account.address.address1, "123 Main St")
#.........这里部分代码省略.........