Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ServiceBus] mode (ReceiveMode) parameter needs better exception behavior #13531

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def _populate_attributes(self, **kwargs):
self._auth_uri = "sb://{}/{}".format(self.fully_qualified_namespace, self.entity_path)
self._entity_uri = "amqps://{}/{}".format(self.fully_qualified_namespace, self.entity_path)
self._receive_mode = kwargs.get("receive_mode", ReceiveMode.PeekLock)
# While we try to leave failures to the service, in this case the errors lower down the stack are less clear.
if not isinstance(self._receive_mode, ReceiveMode):
raise TypeError("Parameter 'receive_mode' must be of type ReceiveMode")

self._error_policy = _ServiceBusErrorPolicy(
max_retries=self._config.retry_total
)
Expand Down
11 changes: 6 additions & 5 deletions sdk/servicebus/azure-servicebus/tests/test_queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -1857,11 +1857,12 @@ def test_queue_receiver_invalid_mode(self, servicebus_namespace_connection_strin

with ServiceBusClient.from_connection_string(
servicebus_namespace_connection_string, logging_enable=False) as sb_client:
# with pytest.raises(StopIteration):
with sb_client.get_queue_receiver(servicebus_queue.name,
max_wait_time="oij") as receiver:

assert receiver
with pytest.raises(TypeError):
with sb_client.get_queue_receiver(servicebus_queue.name,
receive_mode=2) as receiver:

raise Exception("Should not get here, should fail fast.")


@pytest.mark.liveTest
@pytest.mark.live_test_only
Expand Down