Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the App Configuration Provider test suite to reduce reliance on real-time delays and repeated per-test data setup by centralizing test data creation and forcing refresh timers to expire in tests.
Changes:
- Centralize test key/snapshot creation into a session-scoped pytest fixture and remove per-test
setup_configscalls. - Replace
sleep-based refresh timing with forced expiration of internal refresh timers. - Add per-test restoration logic for settings/feature flags that are modified during snapshot/refresh tests.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| sdk/appconfiguration/azure-appconfiguration-provider/tests/testcase.py | Moves snapshot-related helpers/imports to module scope and expands setup_configs to create snapshot test data and snapshots. |
| sdk/appconfiguration/azure-appconfiguration-provider/tests/conftest.py | Adds a session autouse fixture to pre-populate keys/snapshots in live mode and stores snapshot names for tests. |
| sdk/appconfiguration/azure-appconfiguration-provider/tests/test_snapshots.py | Updates snapshot integration tests to use pre-created snapshots and timer-expiration instead of sleep; adds restoration of modified keys. |
| sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_refresh.py | Replaces sleep with forced refresh timer expiry; adds cleanup/reset of modified settings. |
| sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_feature_management.py | Removes per-test setup_configs call, relying on session setup. |
| sdk/appconfiguration/azure-appconfiguration-provider/tests/key_vault/test_secret_refresh.py | Removes sleep usage and adds timer-expiration + restoration in updated secret test. |
| sdk/appconfiguration/azure-appconfiguration-provider/tests/asynctestcase.py | Removes async per-test setup_configs call to align with centralized setup approach. |
| sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/test_configuration_async_client_manager.py | Removes polling loop/sleeps after refresh_clients(); asserts replica client count directly. |
| sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/test_async_snapshots.py | Mirrors sync snapshot test updates for async: pre-created snapshots, timer expiry, and restoration logic. |
| sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/test_async_provider_refresh.py | Mirrors sync refresh test updates for async by expiring refresh timers and resetting modified settings. |
| sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/test_async_provider_feature_management.py | Removes per-test setup_configs call, relying on session setup. |
| sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/key_vault/test_async_secret_refresh.py | Removes async sleeps and adds timer-expiration + restoration in updated secret test. |
| sdk/appconfiguration/azure-appconfiguration-provider/assets.json | Updates the assets tag for refreshed recordings/assets. |
Comments suppressed due to low confidence (2)
sdk/appconfiguration/azure-appconfiguration-provider/tests/key_vault/test_secret_refresh.py:66
- This test patches
client.refreshand then assertsmock_refresh.call_countafter callingclient.refresh(). That will always pass regardless of whethersecret_refresh_intervallogic works, so it no longer validates the timer-driven refresh behavior described by the test name/docstring. Update the test to exercise the actual secret refresh timer (e.g., force-expireclient._secret_provider.secret_refresh_timer/ patchtime.timesoneeds_refresh()flips, then verify that the underlying secret resolution changes or the on-refresh callback fires).
# Mock the refresh method to track calls
with patch.object(client, "refresh") as mock_refresh:
client.refresh()
# Verify refresh was called
assert mock_refresh.call_count >= 1
client.refresh()
# Should have been called at least twice now
assert mock_refresh.call_count >= 2
sdk/appconfiguration/azure-appconfiguration-provider/tests/aio/key_vault/test_async_secret_refresh.py:73
- This test patches
client.refreshand then assertsmock_refresh.call_countafter awaitingclient.refresh(), which will always pass even if the secret refresh interval logic is broken. To keep the test meaningful, avoid mocking out the method under test and instead force-expire the secret refresh timer (or patchtime.time/needs_refresh) and verify that the secret value or refresh callback changes as expected.
# Mock the refresh method to track calls
with patch.object(client, "refresh") as mock_refresh:
await client.refresh()
# Verify refresh was called
assert mock_refresh.call_count >= 1
await client.refresh()
# Should have been called at least twice now
assert mock_refresh.call_count >= 2
You can also share your feedback on Copilot code review. Take the survey.
| snapshot_names["snapshot"] = snap_name | ||
| snapshot_names["ff_snapshot"] = ff_snap_name | ||
|
|
||
| yield |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Updates how the tests are run for the App Config Provider:
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines