-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Python: Add tests to Purview Package #3513
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
284e15b to
ccee939
Compare
ccee939 to
9de9128
Compare
Motivation and Context
Add Tests for test coverage
Description
Add Tests for test coverage. Increased test coverage from 84 to 89 percent.
Contribution Checklist