本文整理汇总了Python中cloudant.account.Cloudant.volume_usage方法的典型用法代码示例。如果您正苦于以下问题:Python Cloudant.volume_usage方法的具体用法?Python Cloudant.volume_usage怎么用?Python Cloudant.volume_usage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudant.account.Cloudant
的用法示例。
在下文中一共展示了Cloudant.volume_usage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_volume_usage
# 需要导入模块: from cloudant.account import Cloudant [as 别名]
# 或者: from cloudant.account.Cloudant import volume_usage [as 别名]
def test_volume_usage(self):
with mock.patch(
'cloudant.account.Cloudant._usage_endpoint'
) as mock_usage:
mock_usage.return_value = {'usage': 'mock'}
c = Cloudant(self.username, self.password, account=self.username)
c.connect()
bill = c.volume_usage(2015, 12)
self.assertEqual(bill, mock_usage.return_value)
示例2: CloudantAccountTests
# 需要导入模块: from cloudant.account import Cloudant [as 别名]
# 或者: from cloudant.account.Cloudant import volume_usage [as 别名]
class CloudantAccountTests(UnitTestDbBase):
"""
Cloudant specific Account unit tests
"""
def test_constructor_with_account(self):
"""
Test instantiating an account object using an account name
"""
# Ensure that the client is new
del self.client
self.client = Cloudant(self.user, self.pwd, account=self.account)
self.assertEqual(
self.client.cloudant_url,
'https://{0}.cloudant.com'.format(self.account)
)
def test_connect_headers(self):
"""
Test that the appropriate request headers are set
"""
try:
self.client.connect()
self.assertEqual(
self.client.r_session.headers['X-Cloudant-User'],
self.account
)
agent = self.client.r_session.headers.get('User-Agent')
self.assertTrue(agent.startswith('python-cloudant'))
finally:
self.client.disconnect()
def test_billing_data(self):
"""
Test the retrieval of billing data
"""
try:
self.client.connect()
expected = [
'data_volume',
'total',
'start',
'end',
'http_heavy',
'http_light'
]
# Test using year and month
year = datetime.now().year
month = datetime.now().month
data = self.client.bill(year, month)
self.assertTrue(all(x in expected for x in data.keys()))
#Test without year and month arguments
del data
data = self.client.bill()
self.assertTrue(all(x in expected for x in data.keys()))
finally:
self.client.disconnect()
def test_volume_usage_data(self):
"""
Test the retrieval of volume usage data
"""
try:
self.client.connect()
expected = [
'data_vol',
'granularity',
'start',
'end'
]
# Test using year and month
year = datetime.now().year
month = datetime.now().month
data = self.client.volume_usage(year, month)
self.assertTrue(all(x in expected for x in data.keys()))
#Test without year and month arguments
del data
data = self.client.volume_usage()
self.assertTrue(all(x in expected for x in data.keys()))
finally:
self.client.disconnect()
def test_requests_usage_data(self):
"""
Test the retrieval of requests usage data
"""
try:
self.client.connect()
expected = [
'requests',
'granularity',
'start',
'end'
]
# Test using year and month
year = datetime.now().year
month = datetime.now().month
data = self.client.requests_usage(year, month)
self.assertTrue(all(x in expected for x in data.keys()))
#Test without year and month arguments
#.........这里部分代码省略.........