def setUp(self): self.sbs = ServiceBusService(credentials.getServiceBusNamespace(), credentials.getServiceBusKey(), 'owner') set_service_options(self.sbs) self.queue_name = getUniqueName('utqueue') self.topic_name = getUniqueName('uttopic') self.additional_queue_names = [] self.additional_topic_names = []
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 AZURE_SERVICEBUS_NAMESPACE in os.environ: del os.environ[AZURE_SERVICEBUS_NAMESPACE] if AZURE_SERVICEBUS_ACCESS_KEY in os.environ: del os.environ[AZURE_SERVICEBUS_ACCESS_KEY] if AZURE_SERVICEBUS_ISSUER in os.environ: del os.environ[AZURE_SERVICEBUS_ISSUER] # Assert self.assertIsNotNone(sbs) self.assertEqual(sbs.service_namespace, credentials.getServiceBusNamespace()) self.assertEqual(sbs.account_key, credentials.getServiceBusKey()) self.assertEqual(sbs.issuer, 'owner')
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 = []
------------------------------------ >>> msg = bus_service.receive_queue_message('taskqueue') >>> print(msg.body) Test Message >>> msg = Message('Test Message') >>> bus_service.send_queue_message('taskqueue', msg) >>> msg = bus_service.receive_queue_message('taskqueue', peek_lock=True) >>> print(msg.body) Test Message >>> msg.delete() >>> bus_service.delete_queue('taskqueue') True >>> bus_service.delete_queue('taskqueue2') True """ from util import credentials ns = credentials.getServiceBusNamespace() key = credentials.getServiceBusKey() if __name__ == "__main__": import doctest doctest.testmod()
How to Receive Messages from a Queue ------------------------------------ >>> msg = bus_service.receive_queue_message('taskqueue') >>> print(msg.body) Test Message >>> msg = Message('Test Message') >>> bus_service.send_queue_message('taskqueue', msg) >>> msg = bus_service.receive_queue_message('taskqueue', peek_lock=True) >>> print(msg.body) Test Message >>> msg.delete() >>> bus_service.delete_queue('taskqueue') True >>> bus_service.delete_queue('taskqueue2') True """ from util import credentials ns = credentials.getServiceBusNamespace() key = credentials.getServiceBusKey() if __name__ == "__main__": import doctest doctest.testmod()