-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Updating App Config test resources #48769
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bdeaf51
Updating App Config test resources
mrm9084 f2bbac1
Update test_readiness.py
mrm9084 420c359
Apply batched suggestions from code review
mrm9084 0556c41
updating from review comments
mrm9084 ebf8dd7
Apply batched suggestions from code review
mrm9084 42d52a7
Updating samples
mrm9084 fce871f
review items
mrm9084 544898c
Fixing provider tests
mrm9084 f2783a4
Update conftest.py
mrm9084 c983ba6
Fixing tests
mrm9084 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
Some comments aren't visible on the classic Files Changed page.
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
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
60 changes: 60 additions & 0 deletions
60
sdk/appconfiguration/azure-appconfiguration-provider/tests/test_readiness.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,60 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
| from unittest.mock import MagicMock, patch | ||
|
|
||
| import pytest | ||
| from azure.core.exceptions import HttpResponseError | ||
|
|
||
| from conftest import _wait_for_data_plane_access | ||
|
mrm9084 marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| def _http_error(status_code): | ||
| response = MagicMock() | ||
| response.status_code = status_code | ||
| response.reason = "Forbidden" | ||
| return HttpResponseError(response=response) | ||
|
|
||
|
|
||
| def test_wait_for_data_plane_access_succeeds_immediately(): | ||
| client = MagicMock() | ||
| client.list_configuration_settings.return_value = iter([]) | ||
|
|
||
| with patch("conftest.time.sleep") as sleep: | ||
| _wait_for_data_plane_access(client) | ||
|
|
||
| sleep.assert_not_called() | ||
|
|
||
|
|
||
| def test_wait_for_data_plane_access_retries_forbidden_response(): | ||
| client = MagicMock() | ||
| client.list_configuration_settings.side_effect = [_http_error(403), iter([])] | ||
|
|
||
| with patch("conftest.time.sleep") as sleep: | ||
| _wait_for_data_plane_access(client) | ||
|
|
||
| sleep.assert_called_once_with(1) | ||
|
|
||
|
|
||
| def test_wait_for_data_plane_access_does_not_retry_other_errors(): | ||
| client = MagicMock() | ||
| client.list_configuration_settings.side_effect = _http_error(500) | ||
|
|
||
| with patch("conftest.time.sleep") as sleep, pytest.raises(HttpResponseError): | ||
| _wait_for_data_plane_access(client) | ||
|
|
||
| sleep.assert_not_called() | ||
|
|
||
|
|
||
| def test_wait_for_data_plane_access_times_out(): | ||
| client = MagicMock() | ||
| client.list_configuration_settings.side_effect = _http_error(403) | ||
|
|
||
| with patch("conftest.time.monotonic", side_effect=[0, 2]), patch( | ||
| "conftest.time.sleep" | ||
| ) as sleep, pytest.raises(TimeoutError): | ||
| _wait_for_data_plane_access(client, timeout=1) | ||
|
|
||
| sleep.assert_not_called() | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.