fix: Add mock_testing to Presidio unit tests and fix enterprise base_email imports #16424
+7
−3
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.
Title
fix: Add mock_testing to Presidio unit tests and fix enterprise base_email imports
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unitType
✅ Test
Changes
Summary
Fixes 2 failing unit tests that were missed in recent test cleanup:
Changes
1. Presidio Tests (Unit Tests)
Added
mock_testing=Trueto 2 test functions that were creating_OPTIONAL_PresidioPIIMaskingdirectly instead of using thepresidio_guardrailfixture.Files changed:
tests/test_litellm/proxy/guardrails/guardrail_hooks/test_presidio.pyTests fixed:
test_presidio_sets_guardrail_information_in_request_data✅test_request_data_flows_to_apply_guardrail✅Why this fix: Without
mock_testing=True, the Presidio class tries to validatePRESIDIO_ANALYZER_API_BASEenvironment variable which isn't needed for unit tests.2. Enterprise Email Tests
Changed absolute imports to relative imports in
base_email.pyto use local code instead of package.Files changed:
enterprise/litellm_enterprise/enterprise_callbacks/send_emails/base_email.pytests/test_litellm/enterprise/enterprise_callbacks/send_emails/test_base_email.pyTests fixed:
test_base_email.py✅The
litellm-enterprise==0.1.20package in site-packages is outdated and missingSendKeyRotatedEmailEvent. Using relative imports ensures main code is used.Testing
Enterprise email tests
poetry run pytest tests/test_litellm/enterprise/enterprise_callbacks/send_emails/test_base_email.py -v # 18 passedNote for Maintainers