本文整理汇总了Python中azure.servicebus.ServiceBusService.delete_queue方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceBusService.delete_queue方法的具体用法?Python ServiceBusService.delete_queue怎么用?Python ServiceBusService.delete_queue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类azure.servicebus.ServiceBusService
的用法示例。
在下文中一共展示了ServiceBusService.delete_queue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_two_identities
# 需要导入模块: from azure.servicebus import ServiceBusService [as 别名]
# 或者: from azure.servicebus.ServiceBusService import delete_queue [as 别名]
def test_two_identities(self):
# In order to run this test, 2 service bus service identities are created using
# the sbaztool available at:
# http://code.msdn.microsoft.com/windowsazure/Authorization-SBAzTool-6fd76d93
#
# Use the following commands to create 2 identities and grant access rights.
# Replace <servicebusnamespace> with the namespace specified in the test .json file
# Replace <servicebuskey> with the key specified in the test .json file
# This only needs to be executed once, after the service bus namespace is created.
#
# sbaztool makeid user1 NoHEoD6snlvlhZm7yek9Etxca3l0CYjfc19ICIJZoUg= -n <servicebusnamespace> -k <servicebuskey>
# sbaztool grant Send /path1 user1 -n <servicebusnamespace> -k <servicebuskey>
# sbaztool grant Listen /path1 user1 -n <servicebusnamespace> -k <servicebuskey>
# sbaztool grant Manage /path1 user1 -n <servicebusnamespace> -k <servicebuskey>
# sbaztool makeid user2 Tb6K5qEgstyRBwp86JEjUezKj/a+fnkLFnibfgvxvdg= -n <servicebusnamespace> -k <servicebuskey>
# sbaztool grant Send /path2 user2 -n <servicebusnamespace> -k <servicebuskey>
# sbaztool grant Listen /path2 user2 -n <servicebusnamespace> -k <servicebuskey>
# sbaztool grant Manage /path2 user2 -n <servicebusnamespace> -k <servicebuskey>
sbs1 = ServiceBusService(credentials.getServiceBusNamespace(),
'NoHEoD6snlvlhZm7yek9Etxca3l0CYjfc19ICIJZoUg=',
'user1')
sbs2 = ServiceBusService(credentials.getServiceBusNamespace(),
'Tb6K5qEgstyRBwp86JEjUezKj/a+fnkLFnibfgvxvdg=',
'user2')
queue1_name = 'path1/queue' + str(random.randint(1, 10000000))
queue2_name = 'path2/queue' + str(random.randint(1, 10000000))
try:
# Create queues, success
sbs1.create_queue(queue1_name)
sbs2.create_queue(queue2_name)
# Receive messages, success
msg = sbs1.receive_queue_message(queue1_name, True, 1)
self.assertIsNone(msg.body)
msg = sbs1.receive_queue_message(queue1_name, True, 1)
self.assertIsNone(msg.body)
msg = sbs2.receive_queue_message(queue2_name, True, 1)
self.assertIsNone(msg.body)
msg = sbs2.receive_queue_message(queue2_name, True, 1)
self.assertIsNone(msg.body)
# Receive messages, failure
with self.assertRaises(HTTPError):
msg = sbs1.receive_queue_message(queue2_name, True, 1)
with self.assertRaises(HTTPError):
msg = sbs2.receive_queue_message(queue1_name, True, 1)
finally:
try:
sbs1.delete_queue(queue1_name)
except: pass
try:
sbs2.delete_queue(queue2_name)
except: pass
示例2: ServiceBusTest
# 需要导入模块: from azure.servicebus import ServiceBusService [as 别名]
# 或者: from azure.servicebus.ServiceBusService import delete_queue [as 别名]
class ServiceBusTest(AzureTestCase):
def setUp(self):
self.sbs = ServiceBusService(credentials.getServiceBusNamespace(),
credentials.getServiceBusKey(),
'owner')
self.sbs.set_proxy(credentials.getProxyHost(),
credentials.getProxyPort(),
credentials.getProxyUser(),
credentials.getProxyPassword())
__uid = getUniqueTestRunID()
queue_base_name = u'mytestqueue%s' % (__uid)
topic_base_name = u'mytesttopic%s' % (__uid)
self.queue_name = getUniqueNameBasedOnCurrentTime(queue_base_name)
self.topic_name = getUniqueNameBasedOnCurrentTime(topic_base_name)
self.additional_queue_names = []
self.additional_topic_names = []
def tearDown(self):
self.cleanup()
return super(ServiceBusTest, self).tearDown()
def cleanup(self):
try:
self.sbs.delete_queue(self.queue_name)
except:
pass
for name in self.additional_queue_names:
try:
self.sbs.delete_queue(name)
except:
pass
try:
self.sbs.delete_topic(self.topic_name)
except:
pass
for name in self.additional_topic_names:
try:
self.sbs.delete_topic(name)
except:
pass
#--Helpers-----------------------------------------------------------------
def _create_queue(self, queue_name):
self.sbs.create_queue(queue_name, None, True)
def _create_queue_and_send_msg(self, queue_name, msg):
self._create_queue(queue_name)
self.sbs.send_queue_message(queue_name, msg)
def _create_topic(self, topic_name):
self.sbs.create_topic(topic_name, None, True)
def _create_topic_and_subscription(self, topic_name, subscription_name):
self._create_topic(topic_name)
self._create_subscription(topic_name, subscription_name)
def _create_subscription(self, topic_name, subscription_name):
self.sbs.create_subscription(topic_name, subscription_name, None, True)
#--Test cases for service bus service -------------------------------------
def test_create_service_bus_missing_arguments(self):
# Arrange
if os.environ.has_key(AZURE_SERVICEBUS_NAMESPACE):
del os.environ[AZURE_SERVICEBUS_NAMESPACE]
if os.environ.has_key(AZURE_SERVICEBUS_ACCESS_KEY):
del os.environ[AZURE_SERVICEBUS_ACCESS_KEY]
if os.environ.has_key(AZURE_SERVICEBUS_ISSUER):
del os.environ[AZURE_SERVICEBUS_ISSUER]
# Act
with self.assertRaises(WindowsAzureError):
sbs = ServiceBusService()
# Assert
def test_create_service_bus_env_variables(self):
# Arrange
os.environ[
AZURE_SERVICEBUS_NAMESPACE] = credentials.getServiceBusNamespace()
os.environ[
AZURE_SERVICEBUS_ACCESS_KEY] = credentials.getServiceBusKey()
os.environ[AZURE_SERVICEBUS_ISSUER] = 'owner'
# Act
sbs = ServiceBusService()
if os.environ.has_key(AZURE_SERVICEBUS_NAMESPACE):
del os.environ[AZURE_SERVICEBUS_NAMESPACE]
if os.environ.has_key(AZURE_SERVICEBUS_ACCESS_KEY):
del os.environ[AZURE_SERVICEBUS_ACCESS_KEY]
if os.environ.has_key(AZURE_SERVICEBUS_ISSUER):
#.........这里部分代码省略.........