本文整理汇总了Python中azure.storage.queue.QueueService.list_queues方法的典型用法代码示例。如果您正苦于以下问题:Python QueueService.list_queues方法的具体用法?Python QueueService.list_queues怎么用?Python QueueService.list_queues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类azure.storage.queue.QueueService
的用法示例。
在下文中一共展示了QueueService.list_queues方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: QueueStorageHandlerTest
# 需要导入模块: from azure.storage.queue import QueueService [as 别名]
# 或者: from azure.storage.queue.QueueService import list_queues [as 别名]
class QueueStorageHandlerTest(_TestCase):
def setUp(self):
self.service = QueueService(account_name=ACCOUNT_NAME,
account_key=ACCOUNT_KEY,
is_emulated=_EMULATED)
# ensure that there's no message on the queue before each test
queues = set()
for cfg in LOGGING['handlers'].values():
if 'queue' in cfg:
queues.add(cfg['queue'])
for queue in self.service.list_queues():
if queue.name in queues:
self.service.clear_messages(queue.name)
def test_logging(self):
# get the logger for the test
logger_name = 'queue'
logger = logging.getLogger(logger_name)
handler_name = _get_handler_name(logger_name)
# perform logging
log_text = 'logging test'
logger.info(log_text)
# confirm that the massage has correct log text
queue = _get_handler_config_value(handler_name, 'queue')
messages = iter(self.service.get_messages(queue))
message = next(messages)
text_expected = "INFO %s" % log_text
if _get_handler_config_value(handler_name, 'base64_encoding'):
text_expected = _base64_encode(text_expected)
self.assertEqual(message.content, text_expected)
# confirm that there's no more message in the queue
with self.assertRaises(StopIteration):
next(messages)
def test_message_ttl(self):
# get the logger for the test
logger_name = 'message_ttl'
logger = logging.getLogger(logger_name)
handler_name = _get_handler_name(logger_name)
# perform logging
log_text = 'time-to-live test'
logger.info(log_text)
# confirm that the new message is visible till the ttl expires
queue = _get_handler_config_value(handler_name, 'queue')
messages = iter(self.service.get_messages(queue))
message = next(messages)
text_expected = 'INFO %s' % log_text
if _get_handler_config_value(handler_name, 'base64_encoding'):
text_expected = _base64_encode(text_expected)
self.assertEqual(message.content, text_expected)
# confirm that there's no more message in the queue
with self.assertRaises(StopIteration):
next(messages)
# confirm that the new message is invisible after the ttl expires
ttl = _get_handler_config_value(handler_name, 'message_ttl')
time.sleep(int(ttl)+5)
messages = iter(self.service.get_messages(queue))
with self.assertRaises(StopIteration):
next(messages)
def test_visibility_timeout(self):
# get the logger for the test
logger_name = 'visibility_timeout'
logger = logging.getLogger(logger_name)
handler_name = _get_handler_name(logger_name)
# perform logging
log_text = 'visibility test'
logger.info(log_text)
# confirm that the new message is invisible till the timeout expires
queue = _get_handler_config_value(handler_name, 'queue')
messages = iter(self.service.get_messages(queue))
with self.assertRaises(StopIteration):
next(messages)
# confirm that the new message is visible after the timeout expires
timeout = _get_handler_config_value(handler_name, 'visibility_timeout')
time.sleep(int(timeout)+5)
messages = iter(self.service.get_messages(queue))
message = next(messages)
text_expected = 'INFO %s' % log_text
if _get_handler_config_value(handler_name, 'base64_encoding'):
text_expected = _base64_encode(text_expected)
self.assertEqual(message.content, text_expected)
# confirm that there's no more message in the queue
with self.assertRaises(StopIteration):
next(messages)
def test_base64_encoding(self):
# get the logger for the test
#.........这里部分代码省略.........