本文整理汇总了Python中SoftLayer.MessagingManager.list_accounts方法的典型用法代码示例。如果您正苦于以下问题:Python MessagingManager.list_accounts方法的具体用法?Python MessagingManager.list_accounts怎么用?Python MessagingManager.list_accounts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoftLayer.MessagingManager
的用法示例。
在下文中一共展示了MessagingManager.list_accounts方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from SoftLayer import MessagingManager [as 别名]
# 或者: from SoftLayer.MessagingManager import list_accounts [as 别名]
def execute(client, args):
manager = MessagingManager(client)
accounts = manager.list_accounts()
t = Table([
'id', 'name', 'status'
])
for account in accounts:
t.add_row([
account['nodes'][0]['accountName'],
account['name'],
account['status']['name'],
])
return t
示例2: execute
# 需要导入模块: from SoftLayer import MessagingManager [as 别名]
# 或者: from SoftLayer.MessagingManager import list_accounts [as 别名]
def execute(self, args):
manager = MessagingManager(self.client)
accounts = manager.list_accounts()
table = Table([
'id', 'name', 'status'
])
for account in accounts:
if not account['nodes']:
continue
table.add_row([
account['nodes'][0]['accountName'],
account['name'],
account['status']['name'],
])
return table
示例3: MessagingManagerTests
# 需要导入模块: from SoftLayer import MessagingManager [as 别名]
# 或者: from SoftLayer.MessagingManager import list_accounts [as 别名]
class MessagingManagerTests(unittest.TestCase):
def setUp(self):
self.client = MagicMock()
self.manager = MessagingManager(self.client)
def test_list_accounts(self):
self.manager.list_accounts()
self.client['Account'].getMessageQueueAccounts.assert_called_with(
mask=ANY)
def test_get_endpoints(self):
endpoints = self.manager.get_endpoints()
self.assertEqual(endpoints, SoftLayer.managers.messaging.ENDPOINTS)
@patch('SoftLayer.managers.messaging.ENDPOINTS', {
'datacenter01': {
'private': 'private_endpoint', 'public': 'public_endpoint'},
'dal05': {
'private': 'dal05_private', 'public': 'dal05_public'}})
def test_get_endpoint(self):
# Defaults to dal05, public
endpoint = self.manager.get_endpoint()
self.assertEqual(endpoint, 'https://dal05_public')
endpoint = self.manager.get_endpoint(network='private')
self.assertEqual(endpoint, 'https://dal05_private')
endpoint = self.manager.get_endpoint(datacenter='datacenter01')
self.assertEqual(endpoint, 'https://public_endpoint')
endpoint = self.manager.get_endpoint(datacenter='datacenter01',
network='private')
self.assertEqual(endpoint, 'https://private_endpoint')
endpoint = self.manager.get_endpoint(datacenter='datacenter01',
network='private')
self.assertEqual(endpoint, 'https://private_endpoint')
# ERROR CASES
self.assertRaises(
TypeError,
self.manager.get_endpoint, datacenter='doesnotexist')
self.assertRaises(
TypeError,
self.manager.get_endpoint, network='doesnotexist')
@patch('SoftLayer.managers.messaging.MessagingConnection')
def test_get_connection(self, conn):
queue_conn = self.manager.get_connection('QUEUE_ACCOUNT_ID')
conn.assert_called_with(
'QUEUE_ACCOUNT_ID', endpoint='https://dal05.mq.softlayer.net')
conn().authenticate.assert_called_with(
self.client.auth.username, self.client.auth.api_key)
self.assertEqual(queue_conn, conn())
def test_get_connection_no_auth(self):
self.client.auth = None
self.assertRaises(SoftLayerError,
self.manager.get_connection, 'QUEUE_ACCOUNT_ID')
def test_get_connection_no_username(self):
self.client.auth.username = None
self.assertRaises(SoftLayerError,
self.manager.get_connection, 'QUEUE_ACCOUNT_ID')
def test_get_connection_no_api_key(self):
self.client.auth.api_key = None
self.assertRaises(SoftLayerError,
self.manager.get_connection, 'QUEUE_ACCOUNT_ID')
@patch('SoftLayer.managers.messaging.requests.get')
def test_ping(self, get):
result = self.manager.ping()
get.assert_called_with('https://dal05.mq.softlayer.net/v1/ping')
get().raise_for_status.assert_called_with()
self.assertTrue(result)
示例4: render
# 需要导入模块: from SoftLayer import MessagingManager [as 别名]
# 或者: from SoftLayer.MessagingManager import list_accounts [as 别名]
def render(self):
mgr = MessagingManager(get_client())
return render_template('mq_widget_summary.html',
accounts=mgr.list_accounts())