Skip to content

App Config Provider Tests Update#45692

Open
mrm9084 wants to merge 5 commits intoAzure:mainfrom
mrm9084:AppConfigProviderTestRefactor
Open

App Config Provider Tests Update#45692
mrm9084 wants to merge 5 commits intoAzure:mainfrom
mrm9084:AppConfigProviderTestRefactor

Conversation

@mrm9084
Copy link
Member

@mrm9084 mrm9084 commented Mar 13, 2026

Description

Updates how the tests are run for the App Config Provider:

  • Switches from live tests with sleeping for refresh checks to force expiring the refresh interval.
  • Instead of every test creating all of their configs which included making duplicates, the test startup creates all configurations.
  • If a test modifies a key, it resets it as part of the test.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Copilot AI review requested due to automatic review settings March 13, 2026 21:55
@github-actions github-actions bot added the App Configuration Azure.ApplicationModel.Configuration label Mar 13, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_configs calls.
  • 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.refresh and then asserts mock_refresh.call_count after calling client.refresh(). That will always pass regardless of whether secret_refresh_interval logic 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-expire client._secret_provider.secret_refresh_timer / patch time.time so needs_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.refresh and then asserts mock_refresh.call_count after awaiting client.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 patch time.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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

App Configuration Azure.ApplicationModel.Configuration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants