litellm/tests/test_litellm
Cole McIntosh 6578133bb7
Fix user-team association issues in LiteLLM proxy (#12082)
* Fix user-team association issues in LiteLLM proxy

- Update list_team function to properly filter teams using user's teams array instead of only checking members_with_roles field
- Add Field descriptions and docstring to TeamMemberAddRequest and related models for better Swagger/OpenAPI documentation
- Maintain backward compatibility with fallback to members_with_roles if user lookup fails

This ensures users created with teams parameter appear correctly in team views and improves API documentation.

* Fix duplicate member checking in team_member_add endpoint

- Enhanced team_member_add_duplication_check to check both user_id and user_email
- Added additional duplicate prevention logic after user creation/lookup
- Fixed issue where users added by email could be duplicated in teams
- Added logging for debugging duplicate detection

This addresses the bug where adding the same user by email multiple times would create duplicate entries in the team's members_with_roles array.

* Improve duplicate member prevention in team_member_add

- Enhanced early duplicate check to handle both user_id and user_email
- Added late-stage duplicate prevention after user lookup/creation
- Fixed issue where users could be added multiple times by email
- Cleaned up debug logging

Note: There's still an edge case where the duplicate prevention may not work
correctly in all scenarios. This needs further investigation and testing.

* Refactor team_member_add endpoint for improved member management

- Split team_member_add functionality into smaller, dedicated functions for permission validation, member processing, and team member list updates.
- Enhanced permission checks to ensure only authorized users can add members.
- Streamlined member addition logic to reduce redundancy and improve readability.
- Maintained existing functionality while improving code structure and maintainability.

* Add tests for team_member_add helper functions

- Add test for _validate_team_member_add_permissions with admin user
- Add test for _validate_team_member_add_permissions with non-admin user
- Add test for _process_team_members with single member
- Add test for _process_team_members with multiple members
- Add test for _update_team_members_list with new member
- Add test for _update_team_members_list duplicate prevention

These tests ensure the refactored helper functions work correctly
after fixing the PLR0915 linting error.
2025-06-27 21:29:49 -07:00
..
caching fix(redis_cache.py): support pipeline redis lpop for older redis vers… (#11425) 2025-06-05 00:05:54 -07:00
completion_extras/litellm_responses_transformation Completion-To-Responses Bridge: Support passing image url's (#11833) 2025-06-18 12:48:17 -07:00
enterprise/enterprise_callbacks [Feat] Enterprise - Allow dynamically disabling callbacks in request headers (#11985) 2025-06-23 14:32:05 -07:00
experimental_mcp_client
google_genai [Feat] Add Bridge from generateContent <> /chat/completions (#12081) 2025-06-27 11:08:55 -07:00
integrations LiteLLM SDK <-> Proxy improvement (don't transform message client-side) + Bedrock - handle qs:.. in base64 file data + Tag Management - support adding public model names (#11908) 2025-06-19 22:34:18 -07:00
litellm_core_utils [Feat] Add Eleven Labs - Speech To Text Support on LiteLLM (#12119) 2025-06-27 17:50:49 -07:00
llms Bedrock Passthrough cost tracking (/invoke + /converse routes - streaming + non-streaming) (#12123) 2025-06-27 20:01:12 -07:00
passthrough Refactor: bedrock passthrough fixes - migrate to Passthrough SDK (#12089) 2025-06-26 22:51:35 -07:00
proxy Fix user-team association issues in LiteLLM proxy (#12082) 2025-06-27 21:29:49 -07:00
responses Responses API - Add reasoning content support for non-OpenAI providers (#12055) 2025-06-26 14:21:49 -07:00
router_strategy Simplify experimental multi-instance rate limiter - more accurate (#11424) 2025-06-07 11:10:55 -07:00
router_utils Litellm dev 06 25 2025 p2 (#12049) 2025-06-25 21:54:13 -07:00
secret_managers fix(secret-managers): Break AzureCredentialType restriction on AZURE_CREDENTIAL (#11272) 2025-05-31 01:03:08 -07:00
types Convert scientific notation str to int + Bubble up azure content filter results (#11655) 2025-06-11 23:07:22 -07:00
vector_stores [Fix] QA Fixes - Vector Store Object Permissions (#11291) 2025-05-31 09:41:05 -07:00
__init__.py
conftest.py
log.txt
readme.md
test_constants.py
test_cost_calculation_log_level.py fix: change cost calculation logs from INFO to DEBUG level 2025-06-27 11:36:58 -06:00
test_cost_calculator.py VertexAI Anthropic passthrough cost calc fixes + Filter litellm params from request sent to passthrough endpoint (#11992) 2025-06-23 22:24:47 -07:00
test_logging.py
test_main.py fix: tests 2025-05-31 13:14:37 -07:00
test_router.py Store batch output file id in DB + Store batch file status in DB + (experimental) BATCH API COST TRACKING 2025-06-25 22:41:22 -07:00
test_utils.py Fix unpack_defs handling of nested $ref inside anyOf items (#11964) 2025-06-24 09:08:15 -07:00

Testing for litellm/

This directory 1:1 maps the the litellm/ directory, and can only contain mocked tests.

The point of this is to:

  1. Increase test coverage of litellm/
  2. Make it easy for contributors to add tests for the litellm/ package and easily run tests without needing LLM API keys.

File name conventions

  • litellm/proxy/test_caching_routes.py maps to litellm/proxy/caching_routes.py
  • test_<filename>.py maps to litellm/<filename>.py