-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix(servicebus): Forward **kwargs to _build_pipeline in ServiceBusAdministrationClient #45719
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
Open
EldertGrootenboer
wants to merge
5
commits into
Azure:main
Choose a base branch
from
EldertGrootenboer:fix/servicebus-admin-kwargs-44999
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3fa067a
fix: Forward **kwargs to _build_pipeline in ServiceBusAdministrationC…
EldertGrootenboerMS c494011
Merge branch 'main' into fix/servicebus-admin-kwargs-44999
EldertGrootenboer 87e9cdd
Merge branch 'main' into fix/servicebus-admin-kwargs-44999
EldertGrootenboer d8e085f
Merge remote-tracking branch 'origin/main' into fix/servicebus-admin-…
EldertGrootenboerMS 9156eed
ci: fix mypy.ini for mypy 1.19+ and silence pre-existing transport er…
EldertGrootenboerMS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,15 @@ | ||
| [mypy] | ||
| python_version = 3.7 | ||
| python_version = 3.10 | ||
| warn_unused_configs = True | ||
| ignore_missing_imports = True | ||
|
|
||
| # Per-module options: | ||
|
|
||
| [mypy-azure.servicebus.management._generated.*] | ||
| ignore_errors = True | ||
|
|
||
| [mypy-azure.servicebus._transport._uamqp_transport] | ||
| ignore_errors = True | ||
|
|
||
| [mypy-azure.servicebus._transport._pyamqp_transport] | ||
| ignore_errors = True | ||
|
EldertGrootenboer marked this conversation as resolved.
|
||
103 changes: 103 additions & 0 deletions
103
sdk/servicebus/azure-servicebus/tests/test_mgmt_client_kwargs.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
| """Unit tests verifying that ServiceBusAdministrationClient forwards | ||
| **kwargs from __init__ to _build_pipeline (both sync and async). | ||
|
|
||
| Regression test for https://github.com/Azure/azure-sdk-for-python/issues/44999 | ||
| """ | ||
|
|
||
| from unittest.mock import patch, MagicMock | ||
|
|
||
| import pytest | ||
|
|
||
| from azure.servicebus.management import ServiceBusAdministrationClient | ||
|
|
||
|
|
||
| class TestServiceBusAdministrationClientKwargs: | ||
| """Verify kwargs like connection_verify and transport reach _build_pipeline.""" | ||
|
|
||
| def test_sync_build_pipeline_receives_kwargs(self): | ||
| """Sync client should forward **kwargs to _build_pipeline.""" | ||
| credential = MagicMock() | ||
| with patch.object( | ||
| ServiceBusAdministrationClient, | ||
| "_build_pipeline", | ||
| return_value=MagicMock(), | ||
| ) as mock_build: | ||
| ServiceBusAdministrationClient( | ||
| "fake.servicebus.windows.net", | ||
| credential, | ||
| connection_verify="/path/to/ca-bundle.crt", | ||
| ) | ||
| mock_build.assert_called_once() | ||
| call_kwargs = mock_build.call_args.kwargs | ||
| assert call_kwargs.get("connection_verify") == "/path/to/ca-bundle.crt" | ||
|
|
||
| def test_sync_build_pipeline_receives_custom_transport(self): | ||
| """Sync client should forward a custom transport kwarg to _build_pipeline.""" | ||
| credential = MagicMock() | ||
| custom_transport = MagicMock() | ||
| with patch.object( | ||
| ServiceBusAdministrationClient, | ||
| "_build_pipeline", | ||
| return_value=MagicMock(), | ||
| ) as mock_build: | ||
| ServiceBusAdministrationClient( | ||
| "fake.servicebus.windows.net", | ||
| credential, | ||
| transport=custom_transport, | ||
| ) | ||
| mock_build.assert_called_once() | ||
| call_kwargs = mock_build.call_args.kwargs | ||
| assert call_kwargs.get("transport") is custom_transport | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| class TestServiceBusAdministrationClientKwargsAsync: | ||
| """Verify kwargs reach _build_pipeline on the async client.""" | ||
|
|
||
| async def test_async_build_pipeline_receives_kwargs(self): | ||
| """Async client should forward **kwargs to _build_pipeline.""" | ||
| from azure.servicebus.aio.management import ( | ||
| ServiceBusAdministrationClient as AsyncClient, | ||
| ) | ||
|
|
||
| credential = MagicMock() | ||
| with patch.object( | ||
| AsyncClient, | ||
| "_build_pipeline", | ||
| return_value=MagicMock(), | ||
| ) as mock_build: | ||
| AsyncClient( | ||
| "fake.servicebus.windows.net", | ||
| credential, | ||
| connection_verify="/path/to/ca-bundle.crt", | ||
| ) | ||
| mock_build.assert_called_once() | ||
| call_kwargs = mock_build.call_args.kwargs | ||
| assert call_kwargs.get("connection_verify") == "/path/to/ca-bundle.crt" | ||
|
|
||
| async def test_async_build_pipeline_receives_custom_transport(self): | ||
| """Async client should forward a custom transport kwarg to _build_pipeline.""" | ||
| from azure.servicebus.aio.management import ( | ||
| ServiceBusAdministrationClient as AsyncClient, | ||
| ) | ||
|
|
||
| credential = MagicMock() | ||
| custom_transport = MagicMock() | ||
| with patch.object( | ||
| AsyncClient, | ||
| "_build_pipeline", | ||
| return_value=MagicMock(), | ||
| ) as mock_build: | ||
| AsyncClient( | ||
| "fake.servicebus.windows.net", | ||
| credential, | ||
| transport=custom_transport, | ||
| ) | ||
| mock_build.assert_called_once() | ||
| call_kwargs = mock_build.call_args.kwargs | ||
| assert call_kwargs.get("transport") is custom_transport |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.