async def test_async_session_message_expiry(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) session_id = str(uuid.uuid4()) queue_client = client.get_queue(session_queue) async with queue_client.get_sender() as sender: message = Message("Testing expired messages") message.session_id = session_id await sender.send(message) async with queue_client.get_receiver(session=session_id) as receiver: messages = await receiver.fetch_next(timeout=10) assert len(messages) == 1 print_message(messages[0]) await asyncio.sleep(30) with pytest.raises(TypeError): messages[0].expired with pytest.raises(TypeError): await messages[0].renew_lock() assert receiver.expired with pytest.raises(SessionLockExpired): await messages[0].complete() with pytest.raises(SessionLockExpired): await receiver.renew_lock() async with queue_client.get_receiver(session=session_id) as receiver: messages = await receiver.fetch_next(timeout=30) assert len(messages) == 1 print_message(messages[0]) #assert messages[0].header.delivery_count # TODO confirm this with service await messages[0].complete()
async def test_async_session_message_connection_closed(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) session_id = str(uuid.uuid4()) queue_client = client.get_queue(session_queue) async with queue_client.get_sender() as sender: message = Message("test") message.session_id = session_id await sender.send(message) async with queue_client.get_receiver(session=session_id) as receiver: messages = await receiver.fetch_next(timeout=10) assert len(messages) == 1 with pytest.raises(MessageSettleFailed): await messages[0].complete()
async def test_async_session_message_expiry( 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) session_id = str(uuid.uuid4()) queue_client = client.get_queue(servicebus_queue.name) async with queue_client.get_sender() as sender: message = Message("Testing expired messages") message.session_id = session_id await sender.send(message) async with queue_client.get_receiver(session=session_id) as receiver: messages = await receiver.fetch_next(timeout=10) assert len(messages) == 1 print_message(messages[0]) await asyncio.sleep(30) with pytest.raises(TypeError): messages[0].expired with pytest.raises(TypeError): await messages[0].renew_lock() assert receiver.expired with pytest.raises(SessionLockExpired): await messages[0].complete() with pytest.raises(SessionLockExpired): await receiver.renew_lock() async with queue_client.get_receiver(session=session_id) as receiver: messages = await receiver.fetch_next(timeout=30) assert len(messages) == 1 print_message(messages[0]) #assert messages[0].header.delivery_count # TODO confirm this with service await messages[0].complete()
async def test_async_session_message_connection_closed( 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) session_id = str(uuid.uuid4()) queue_client = client.get_queue(servicebus_queue.name) async with queue_client.get_sender() as sender: message = Message("test") message.session_id = session_id await sender.send(message) async with queue_client.get_receiver(session=session_id) as receiver: messages = await receiver.fetch_next(timeout=10) assert len(messages) == 1 with pytest.raises(MessageSettleFailed): await messages[0].complete()