|
25 | 25 | MessageLockExpired,
|
26 | 26 | MessageAlreadySettled,
|
27 | 27 | AutoLockRenewTimeout,
|
28 |
| - MessageSettleFailed) |
| 28 | + MessageSettleFailed, |
| 29 | + MessageSendFailed) |
29 | 30 |
|
30 | 31 | from devtools_testutils import AzureMgmtTestCase, CachedResourceGroupPreparer
|
31 | 32 | from servicebus_preparer import (
|
@@ -903,12 +904,15 @@ def test_session_by_session_client_conn_str_receive_handler_peeklock_abandon(sel
|
903 | 904 | message = Message("Handler message no. {}".format(i), session_id=session_id)
|
904 | 905 | sender.send(message)
|
905 | 906 |
|
906 |
| - with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id, prefetch=0) as receiver: |
| 907 | + with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id, prefetch=0, idle_timeout=5) as receiver: |
907 | 908 | message = receiver.next()
|
908 | 909 | assert message.sequence_number == 1
|
909 | 910 | message.abandon()
|
910 |
| - second_message = receiver.next() |
911 |
| - assert second_message.sequence_number == 1 |
| 911 | + for next_message in receiver: # we can't be sure there won't be a service delay, so we may not get the message back _immediately_, even if in most cases it shows right back up. |
| 912 | + if not next_message: |
| 913 | + raise Exception("Did not successfully re-receive abandoned message, sequence_number 1 was not observed.") |
| 914 | + if next_message.sequence_number == 1: |
| 915 | + return |
912 | 916 |
|
913 | 917 | @pytest.mark.liveTest
|
914 | 918 | @pytest.mark.live_test_only
|
@@ -937,3 +941,17 @@ def test_session_basic_topic_subscription_send_and_receive(self, servicebus_name
|
937 | 941 | message.complete()
|
938 | 942 | assert count == 1
|
939 | 943 |
|
| 944 | + |
| 945 | + @pytest.mark.liveTest |
| 946 | + @pytest.mark.live_test_only |
| 947 | + @CachedResourceGroupPreparer(name_prefix='servicebustest') |
| 948 | + @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') |
| 949 | + @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) |
| 950 | + def test_session_non_session_send_to_session_queue_should_fail(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): |
| 951 | + with ServiceBusClient.from_connection_string( |
| 952 | + servicebus_namespace_connection_string, logging_enable=False) as sb_client: |
| 953 | + |
| 954 | + with sb_client.get_queue_sender(servicebus_queue.name) as sender: |
| 955 | + message = Message("This should be an invalid non session message") |
| 956 | + with pytest.raises(MessageSendFailed): |
| 957 | + sender.send(message) |
0 commit comments