async def test_async_session_by_servicebus_client_browse_messages_client( live_servicebus_config, session_queue): client = ServiceBusClient( service_namespace=live_servicebus_config['hostname'], shared_access_key_name=live_servicebus_config['key_name'], shared_access_key_value=live_servicebus_config['access_key'], debug=True) queue_client = client.get_queue(session_queue) session_id = str(uuid.uuid4()) async with queue_client.get_sender(session=session_id) as sender: for i in range(5): message = Message("Test message no. {}".format(i)) await sender.send(message) with pytest.raises(ValueError): messages = await queue_client.peek(5) messages = await queue_client.peek(5, session=session_id) assert len(messages) == 5 assert all(isinstance(m, PeekMessage) for m in messages) for message in messages: print_message(message) with pytest.raises(TypeError): message.complete()
async def test_async_session_by_servicebus_client_browse_messages_with_receiver( self, servicebus_namespace, servicebus_namespace_key_name, servicebus_namespace_primary_key, servicebus_queue, **kwargs): client = ServiceBusClient( service_namespace=servicebus_namespace.name, shared_access_key_name=servicebus_namespace_key_name, shared_access_key_value=servicebus_namespace_primary_key, debug=False) queue_client = client.get_queue(servicebus_queue.name) session_id = str(uuid.uuid4()) async with queue_client.get_receiver(idle_timeout=5, session=session_id) as receiver: async with queue_client.get_sender(session=session_id) as sender: for i in range(5): message = Message("Test message no. {}".format(i)) await sender.send(message) messages = await receiver.peek(5) assert len(messages) > 0 assert all(isinstance(m, PeekMessage) for m in messages) for message in messages: print_message(message) with pytest.raises(TypeError): message.complete()
async def test_async_queue_by_servicebus_client_browse_messages_client(live_servicebus_config, standard_queue): client = ServiceBusClient( service_namespace=live_servicebus_config['hostname'], shared_access_key_name=live_servicebus_config['key_name'], shared_access_key_value=live_servicebus_config['access_key'], debug=True) queue_client = client.get_queue(standard_queue) async with queue_client.get_sender() as sender: for i in range(5): message = Message("Test message no. {}".format(i)) await sender.send(message) messages = await queue_client.peek(5) assert len(messages) == 5 assert all(isinstance(m, PeekMessage) for m in messages) for message in messages: print_message(message) with pytest.raises(TypeError): message.complete()
async def test_async_queue_by_servicebus_client_browse_messages_with_receiver(live_servicebus_config, standard_queue): client = ServiceBusClient( service_namespace=live_servicebus_config['hostname'], shared_access_key_name=live_servicebus_config['key_name'], shared_access_key_value=live_servicebus_config['access_key'], debug=True) queue_client = client.get_queue(standard_queue) async with queue_client.get_receiver(idle_timeout=5, mode=ReceiveSettleMode.PeekLock) as receiver: async with queue_client.get_sender() as sender: for i in range(5): message = Message("Test message no. {}".format(i)) await sender.send(message) messages = await receiver.peek(5) assert len(messages) > 0 assert all(isinstance(m, PeekMessage) for m in messages) for message in messages: print_message(message) with pytest.raises(TypeError): message.complete()
async def test_async_session_by_servicebus_client_browse_messages_with_receiver(live_servicebus_config, session_queue): client = ServiceBusClient( service_namespace=live_servicebus_config['hostname'], shared_access_key_name=live_servicebus_config['key_name'], shared_access_key_value=live_servicebus_config['access_key'], debug=True) queue_client = client.get_queue(session_queue) session_id = str(uuid.uuid4()) async with queue_client.get_receiver(idle_timeout=5, session=session_id) as receiver: async with queue_client.get_sender(session=session_id) as sender: for i in range(5): message = Message("Test message no. {}".format(i)) await sender.send(message) messages = await receiver.peek(5) assert len(messages) > 0 assert all(isinstance(m, PeekMessage) for m in messages) for message in messages: print_message(message) with pytest.raises(TypeError): message.complete()