Python: Add tests to Purview Package#3513
Merged
giles17 merged 2 commits intomicrosoft:mainfrom Jan 30, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the Purview Python package’s test suite to cover additional edge cases in the processor, middleware, client, and cache components, with a focus on payment-required behavior, correlation IDs, caching semantics, and error handling.
Changes:
- Added processor tests around corrupted cache entries, tenant-level payment-required exception caching, and background re-processing behavior when scopes are modified.
- Expanded middleware and chat middleware tests to cover streaming behavior, 402 Payment Required handling, and
ignore_exceptionsbehavior in both pre- and post-check paths. - Extended Purview client and cache tests to cover correlation ID propagation, 402 handling, deserialization failures, invalid JSON bodies,
ContentActivitiescalls, and conservative cache size-estimation fallbacks.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
python/packages/purview/tests/test_processor.py |
Adds tests for cache behavior (including corrupted entries), tenant-level payment-required caching, and background retry logic when protection scopes change. |
python/packages/purview/tests/test_middleware.py |
Adds agent middleware tests for streaming (post-check skip), 402 behavior, and exception propagation based on ignore_payment_required and ignore_exceptions. |
python/packages/purview/tests/test_client.py |
Extends client tests to cover ETag header precedence, 402 handling (both _post and process_content), correlation ID header/span behavior, deserialization-fallback paths, and content activities. |
python/packages/purview/tests/test_chat_middleware.py |
Adds chat middleware tests for 402 behavior and exception propagation in pre- and post-checks, mirroring agent middleware semantics. |
python/packages/purview/tests/test_cache.py |
Adds a test ensuring _estimate_size falls back to a conservative size when both JSON serialization and sys.getsizeof fail. |
Member
284e15b to
ccee939
Compare
eoindoherty1
approved these changes
Jan 30, 2026
giles17
approved these changes
Jan 30, 2026
ccee939 to
9de9128
Compare
eavanvalkenburg
pushed a commit
to eavanvalkenburg/agent-framework
that referenced
this pull request
Feb 1, 2026
* Add tests to increase code coverage * Add tests to increase code coverage
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.
Motivation and Context
Add Tests for test coverage
Closes #3358
Description
Add Tests for test coverage. Increased test coverage from 84 to 89 percent.
Contribution Checklist