本文整理汇总了Python中cloudant.account.Cloudant.generate_api_key方法的典型用法代码示例。如果您正苦于以下问题:Python Cloudant.generate_api_key方法的具体用法?Python Cloudant.generate_api_key怎么用?Python Cloudant.generate_api_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudant.account.Cloudant
的用法示例。
在下文中一共展示了Cloudant.generate_api_key方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_generate_api_key
# 需要导入模块: from cloudant.account import Cloudant [as 别名]
# 或者: from cloudant.account.Cloudant import generate_api_key [as 别名]
def test_generate_api_key(self):
mock_resp = mock.Mock()
mock_resp.raise_for_status = mock.Mock()
mock_resp.json = mock.Mock()
mock_resp.json.return_value = {'api': 'token'}
self.mock_instance.post = mock.Mock()
self.mock_instance.post.return_value = mock_resp
c = Cloudant(self.username, self.password, account=self.username)
c.connect()
api_key = c.generate_api_key()
self.assertEqual(api_key, {'api': 'token'})
self.assertTrue(mock_resp.raise_for_status.called)
示例2: CloudantAccountTests
# 需要导入模块: from cloudant.account import Cloudant [as 别名]
# 或者: from cloudant.account.Cloudant import generate_api_key [as 别名]
#.........这里部分代码省略.........
"""
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
del data
data = self.client.requests_usage()
self.assertTrue(all(x in expected for x in data.keys()))
finally:
self.client.disconnect()
def test_shared_databases(self):
"""
Test the retrieval of shared database list
"""
try:
self.client.connect()
self.assertIsInstance(self.client.shared_databases(), list)
finally:
self.client.disconnect()
def test_generate_api_key(self):
"""
Test the generation of an API key for this account
"""
try:
self.client.connect()
expected = ['key', 'password', 'ok']
api_key = self.client.generate_api_key()
self.assertTrue(all(x in expected for x in api_key.keys()))
self.assertTrue(api_key['ok'])
finally:
self.client.disconnect()
def test_cors_configuration(self):
"""
Test the retrieval of the current CORS configuration for this account
"""
try:
self.client.connect()
expected = ['allow_credentials', 'enable_cors', 'origins']
cors = self.client.cors_configuration()
self.assertTrue(all(x in expected for x in cors.keys()))
finally:
self.client.disconnect()
def test_cors_origins(self):
"""
Test the retrieval of the CORS origins list
"""
try:
self.client.connect()
origins = self.client.cors_origins()
self.assertIsInstance(origins, list)