diff --git a/.github/merge-smoke-tests.json b/.github/merge-smoke-tests.json index 727733fa954..90d3b6a6d59 100644 --- a/.github/merge-smoke-tests.json +++ b/.github/merge-smoke-tests.json @@ -3,8 +3,8 @@ "CHAT-JSON": "tests/unit/llms/openai/test_openai.py::test_acompletion_returns_json_reply_over_injected_transport", "CHAT-TEXT-STREAM": "tests/unit/llms/openai/test_openai.py::test_acompletion_streams_text_deltas_over_injected_transport", "CHAT-TOOL-STREAM": "tests/unit/llms/openai/test_openai.py::test_acompletion_streams_tool_call_arguments_over_injected_transport", - "MODEL-ALLOW": "tests/test_litellm/proxy/auth/test_auth_checks.py::test_can_object_call_model_allows_listed_model_for_key", - "MODEL-DENY": "tests/test_litellm/proxy/auth/test_auth_checks.py::test_can_object_call_model_denials_return_forbidden[key-key_model_access_denied]", + "MODEL-ALLOW": "tests/unit/proxy/auth/test_auth_checks_object_access_and_lookup.py::test_can_object_call_model_allows_listed_model_for_key", + "MODEL-DENY": "tests/unit/proxy/auth/test_auth_checks_object_access_and_lookup.py::test_can_object_call_model_denials_return_forbidden[key-key_model_access_denied]", "COST-EXPLICIT": "tests/unit/test_cost_calculator.py::test_completion_cost_charges_explicit_per_token_rates_over_registered_ones", "COST-ZERO": "tests/unit/test_cost_calculator.py::test_completion_cost_is_zero_when_explicit_rates_are_zero", "LOG-CONTENT-ON": "tests/unit/litellm_core_utils/test_litellm_logging.py::test_standard_logging_payload_keeps_message_content_when_message_logging_is_on", diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml index d3604a81e8f..3964db706f8 100644 --- a/.github/workflows/test-unit.yml +++ b/.github/workflows/test-unit.yml @@ -119,10 +119,19 @@ jobs: - shard: proxy-auth artifact-name: proxy-auth test-path: >- - tests/test_litellm/proxy/auth - tests/test_litellm/proxy/hooks - tests/test_litellm/proxy/policy_engine - tests/test_litellm/proxy/client + tests/unit/proxy/auth + tests/unit/proxy/hooks + tests/unit/proxy/policy_engine + tests/unit/proxy/client + --ignore=tests/unit/proxy/auth/test_auth_checks.py + --ignore=tests/unit/proxy/auth/test_user_api_key_auth.py + --ignore=tests/unit/proxy/auth/test_default_end_user_budget_simple.py + --ignore=tests/unit/proxy/auth/test_jwt.py + --ignore=tests/unit/proxy/auth/test_models_fallback_endpoint.py + --ignore=tests/unit/proxy/auth/test_multipart_bypass_repro.py + --ignore=tests/unit/proxy/auth/test_proxy_routes.py + --ignore=tests/unit/proxy/hooks/test_banned_keyword_list.py + --ignore=tests/unit/proxy/hooks/test_unit_test_max_model_budget_limiter.py workers: 2 reruns: 2 timeout-minutes: 20 @@ -190,6 +199,8 @@ jobs: tests/test_litellm/proxy/types_utils tests/test_litellm/proxy/logging_endpoints tests/test_litellm/proxy/test_*.py + tests/unit/proxy/test_proxy_server_endpoints_and_startup.py + tests/unit/proxy/test_proxy_utils_model_creation_and_error_logging.py unit-flag: proxy-infra workers: 4 reruns: 2 diff --git a/Makefile b/Makefile index cad3242fbce..704c587fd47 100644 --- a/Makefile +++ b/Makefile @@ -324,10 +324,10 @@ test-unit-proxy-guardrails: install-test-deps $(UV_RUN) pytest tests/test_litellm/proxy/guardrails tests/test_litellm/proxy/management_endpoints tests/test_litellm/proxy/management_helpers --tb=short -vv -n 4 --durations=20 test-unit-proxy-core: install-test-deps - $(UV_RUN) pytest tests/test_litellm/proxy/auth tests/test_litellm/proxy/client tests/test_litellm/proxy/db tests/test_litellm/proxy/hooks tests/test_litellm/proxy/policy_engine --tb=short -vv -n 4 --durations=20 + $(UV_RUN) pytest tests/unit/proxy/auth tests/unit/proxy/client tests/test_litellm/proxy/db tests/unit/proxy/hooks tests/unit/proxy/policy_engine --tb=short -vv -n 4 --durations=20 test-unit-proxy-misc: install-test-deps - $(UV_RUN) pytest tests/test_litellm/proxy/_experimental tests/test_litellm/proxy/agent_endpoints tests/test_litellm/proxy/anthropic_endpoints tests/test_litellm/proxy/common_utils tests/test_litellm/proxy/discovery_endpoints tests/test_litellm/proxy/experimental tests/test_litellm/proxy/google_endpoints tests/test_litellm/proxy/health_endpoints tests/test_litellm/proxy/image_endpoints tests/test_litellm/proxy/middleware tests/test_litellm/proxy/openai_files_endpoint tests/test_litellm/proxy/pass_through_endpoints tests/test_litellm/proxy/prompts tests/test_litellm/proxy/public_endpoints tests/test_litellm/proxy/response_api_endpoints tests/test_litellm/proxy/shutdown tests/test_litellm/proxy/spend_tracking tests/test_litellm/proxy/ui_crud_endpoints tests/test_litellm/proxy/vector_store_endpoints tests/test_litellm/proxy/test_*.py --tb=short -vv -n 4 --durations=20 + $(UV_RUN) pytest tests/test_litellm/proxy/_experimental tests/test_litellm/proxy/agent_endpoints tests/test_litellm/proxy/anthropic_endpoints tests/test_litellm/proxy/common_utils tests/test_litellm/proxy/discovery_endpoints tests/test_litellm/proxy/experimental tests/test_litellm/proxy/google_endpoints tests/test_litellm/proxy/health_endpoints tests/test_litellm/proxy/image_endpoints tests/test_litellm/proxy/middleware tests/test_litellm/proxy/openai_files_endpoint tests/test_litellm/proxy/pass_through_endpoints tests/test_litellm/proxy/prompts tests/test_litellm/proxy/public_endpoints tests/test_litellm/proxy/response_api_endpoints tests/test_litellm/proxy/shutdown tests/test_litellm/proxy/spend_tracking tests/test_litellm/proxy/ui_crud_endpoints tests/test_litellm/proxy/vector_store_endpoints tests/test_litellm/proxy/test_*.py tests/unit/proxy/test_proxy_server_endpoints_and_startup.py tests/unit/proxy/test_proxy_utils_model_creation_and_error_logging.py tests/unit/proxy/_experimental/mcp_server/test_mcp_server_tool_calls_and_headers.py --tb=short -vv -n 4 --durations=20 test-unit-integrations: install-test-deps $(UV_RUN) pytest tests/unit/integrations --tb=short -vv -n 4 --durations=20 diff --git a/tests/proxy_behavior/auth/test_auth_object_prefetch.py b/tests/proxy_behavior/auth/test_auth_object_prefetch.py index cfa958500af..2d3b6da2a45 100644 --- a/tests/proxy_behavior/auth/test_auth_object_prefetch.py +++ b/tests/proxy_behavior/auth/test_auth_object_prefetch.py @@ -1,6 +1,6 @@ """Runs the auth prefetch's raw SQL against a real Postgres: the join must bind the membership to the requested team and hand the getters rows they validate. The per-regime round-trip counts are unit-tested with fakes in -tests/test_litellm/proxy/auth/test_auth_object_prefetch.py.""" +tests/unit/proxy/auth/test_auth_object_prefetch.py.""" import json from unittest.mock import AsyncMock, MagicMock diff --git a/tests/unit/proxy/_experimental/mcp_server/conftest.py b/tests/unit/proxy/_experimental/mcp_server/conftest.py index d8b91e07467..51cab559797 100644 --- a/tests/unit/proxy/_experimental/mcp_server/conftest.py +++ b/tests/unit/proxy/_experimental/mcp_server/conftest.py @@ -1,5 +1,6 @@ import asyncio import importlib +import os import pytest @@ -76,3 +77,62 @@ def config_only_mcp_manager_factory(): return None return ConfigOnlyManager + + +@pytest.fixture(autouse=True) +def _hermetic_mcp_server_registry(): + from litellm.proxy._experimental.mcp_server.mcp_server_manager import ( + global_mcp_server_manager, + ) + + saved_registry = dict(global_mcp_server_manager.registry) + saved_config_servers = dict(global_mcp_server_manager.config_mcp_servers) + saved_tool_mapping = dict(global_mcp_server_manager.tool_name_to_mcp_server_name_mapping) + saved_oauth_slots = global_mcp_server_manager._oauth_discovery_slots + global_mcp_server_manager.registry.clear() + global_mcp_server_manager.config_mcp_servers.clear() + global_mcp_server_manager.tool_name_to_mcp_server_name_mapping.clear() + global_mcp_server_manager._oauth_discovery_slots = () + try: + yield + finally: + global_mcp_server_manager.registry.clear() + global_mcp_server_manager.registry.update(saved_registry) + global_mcp_server_manager.config_mcp_servers.clear() + global_mcp_server_manager.config_mcp_servers.update(saved_config_servers) + global_mcp_server_manager.tool_name_to_mcp_server_name_mapping.clear() + global_mcp_server_manager.tool_name_to_mcp_server_name_mapping.update(saved_tool_mapping) + global_mcp_server_manager._oauth_discovery_slots = saved_oauth_slots + + +@pytest.fixture(autouse=True) +def _hermetic_server_root_path(): + saved = os.environ.pop("SERVER_ROOT_PATH", None) + try: + yield + finally: + if saved is not None: + os.environ["SERVER_ROOT_PATH"] = saved + + +@pytest.fixture +def _mcp_request_ctx(): + def _mcp_request_ctx(**overrides): + from types import SimpleNamespace + + from mcp.server.context import ServerRequestContext + + kwargs = { + "session": SimpleNamespace(), + "lifespan_context": {}, + "protocol_version": "2025-06-18", + "method": "", + "params": None, + "request_id": 1, + "meta": None, + "request": None, + } + kwargs.update(overrides) + return ServerRequestContext(**kwargs) + + return _mcp_request_ctx diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server.py b/tests/unit/proxy/_experimental/mcp_server/test_mcp_server_tool_calls_and_headers.py similarity index 100% rename from tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server.py rename to tests/unit/proxy/_experimental/mcp_server/test_mcp_server_tool_calls_and_headers.py diff --git a/tests/test_litellm/proxy/auth/test_admin_viewer_handler_access.py b/tests/unit/proxy/auth/test_admin_viewer_handler_access.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_admin_viewer_handler_access.py rename to tests/unit/proxy/auth/test_admin_viewer_handler_access.py diff --git a/tests/test_litellm/proxy/auth/test_auth_checks.py b/tests/unit/proxy/auth/test_auth_checks_object_access_and_lookup.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_auth_checks.py rename to tests/unit/proxy/auth/test_auth_checks_object_access_and_lookup.py diff --git a/tests/test_litellm/proxy/auth/test_auth_exception_handler.py b/tests/unit/proxy/auth/test_auth_exception_handler.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_auth_exception_handler.py rename to tests/unit/proxy/auth/test_auth_exception_handler.py diff --git a/tests/test_litellm/proxy/auth/test_auth_hot_path_network_requests.py b/tests/unit/proxy/auth/test_auth_hot_path_network_requests.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_auth_hot_path_network_requests.py rename to tests/unit/proxy/auth/test_auth_hot_path_network_requests.py diff --git a/tests/test_litellm/proxy/auth/test_auth_object_prefetch.py b/tests/unit/proxy/auth/test_auth_object_prefetch.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_auth_object_prefetch.py rename to tests/unit/proxy/auth/test_auth_object_prefetch.py diff --git a/tests/test_litellm/proxy/auth/test_auth_utils.py b/tests/unit/proxy/auth/test_auth_utils.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_auth_utils.py rename to tests/unit/proxy/auth/test_auth_utils.py diff --git a/tests/test_litellm/proxy/auth/test_banned_params_extra_body.py b/tests/unit/proxy/auth/test_banned_params_extra_body.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_banned_params_extra_body.py rename to tests/unit/proxy/auth/test_banned_params_extra_body.py diff --git a/tests/test_litellm/proxy/auth/test_cli_auth.py b/tests/unit/proxy/auth/test_cli_auth.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_cli_auth.py rename to tests/unit/proxy/auth/test_cli_auth.py diff --git a/tests/test_litellm/proxy/auth/test_custom_auth_end_user_budget.py b/tests/unit/proxy/auth/test_custom_auth_end_user_budget.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_custom_auth_end_user_budget.py rename to tests/unit/proxy/auth/test_custom_auth_end_user_budget.py diff --git a/tests/test_litellm/proxy/auth/test_fallback_budget.py b/tests/unit/proxy/auth/test_fallback_budget.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_fallback_budget.py rename to tests/unit/proxy/auth/test_fallback_budget.py diff --git a/tests/test_litellm/proxy/auth/test_fallback_model_access.py b/tests/unit/proxy/auth/test_fallback_model_access.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_fallback_model_access.py rename to tests/unit/proxy/auth/test_fallback_model_access.py diff --git a/tests/test_litellm/proxy/auth/test_handle_jwt.py b/tests/unit/proxy/auth/test_handle_jwt.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_handle_jwt.py rename to tests/unit/proxy/auth/test_handle_jwt.py diff --git a/tests/test_litellm/proxy/auth/test_info_routes.py b/tests/unit/proxy/auth/test_info_routes.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_info_routes.py rename to tests/unit/proxy/auth/test_info_routes.py diff --git a/tests/test_litellm/proxy/auth/test_litellm_license.py b/tests/unit/proxy/auth/test_litellm_license.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_litellm_license.py rename to tests/unit/proxy/auth/test_litellm_license.py diff --git a/tests/test_litellm/proxy/auth/test_login_utils.py b/tests/unit/proxy/auth/test_login_utils.py similarity index 99% rename from tests/test_litellm/proxy/auth/test_login_utils.py rename to tests/unit/proxy/auth/test_login_utils.py index 1b15994e777..28ca47d01de 100644 --- a/tests/test_litellm/proxy/auth/test_login_utils.py +++ b/tests/unit/proxy/auth/test_login_utils.py @@ -15,6 +15,7 @@ from unittest.mock import AsyncMock, MagicMock, patch import httpx import pytest +import respx if TYPE_CHECKING: from litellm.proxy.auth.login_throttle import LoginThrottle @@ -1978,10 +1979,15 @@ class TestDisableEnvCredentialLogin: assert exc_info.value.code == "401" @pytest.mark.asyncio - async def test_db_user_login_still_works_when_disabled(self): + @respx.mock + async def test_db_user_login_still_works_when_disabled(self, httpx_transport): master_key = "sk-1234" user_email = "admin@example.com" password = "Str0ng!Passw0rd" + sha1 = hashlib.sha1(password.encode("utf-8"), usedforsecurity=False).hexdigest().upper() + respx.get(f"https://api.pwnedpasswords.com/range/{sha1[:5]}").mock( + return_value=httpx.Response(200, text="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA:41") + ) mock_user = LiteLLM_UserTable( user_id="db-admin-1", diff --git a/tests/test_litellm/proxy/auth/test_master_key_boot_check.py b/tests/unit/proxy/auth/test_master_key_boot_check.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_master_key_boot_check.py rename to tests/unit/proxy/auth/test_master_key_boot_check.py diff --git a/tests/test_litellm/proxy/auth/test_mcp_ip_filtering.py b/tests/unit/proxy/auth/test_mcp_ip_filtering.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_mcp_ip_filtering.py rename to tests/unit/proxy/auth/test_mcp_ip_filtering.py diff --git a/tests/test_litellm/proxy/auth/test_model_access_group_budgets.py b/tests/unit/proxy/auth/test_model_access_group_budgets.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_model_access_group_budgets.py rename to tests/unit/proxy/auth/test_model_access_group_budgets.py diff --git a/tests/test_litellm/proxy/auth/test_model_checks.py b/tests/unit/proxy/auth/test_model_checks.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_model_checks.py rename to tests/unit/proxy/auth/test_model_checks.py diff --git a/tests/test_litellm/proxy/auth/test_model_checks_fallbacks.py b/tests/unit/proxy/auth/test_model_checks_fallbacks.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_model_checks_fallbacks.py rename to tests/unit/proxy/auth/test_model_checks_fallbacks.py diff --git a/tests/test_litellm/proxy/auth/test_multi_budget_windows.py b/tests/unit/proxy/auth/test_multi_budget_windows.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_multi_budget_windows.py rename to tests/unit/proxy/auth/test_multi_budget_windows.py diff --git a/tests/test_litellm/proxy/auth/test_network.py b/tests/unit/proxy/auth/test_network.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_network.py rename to tests/unit/proxy/auth/test_network.py diff --git a/tests/test_litellm/proxy/auth/test_oauth2_proxy_hook.py b/tests/unit/proxy/auth/test_oauth2_proxy_hook.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_oauth2_proxy_hook.py rename to tests/unit/proxy/auth/test_oauth2_proxy_hook.py diff --git a/tests/test_litellm/proxy/auth/test_object_permission_loading.py b/tests/unit/proxy/auth/test_object_permission_loading.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_object_permission_loading.py rename to tests/unit/proxy/auth/test_object_permission_loading.py diff --git a/tests/test_litellm/proxy/auth/test_onboarding.py b/tests/unit/proxy/auth/test_onboarding.py similarity index 99% rename from tests/test_litellm/proxy/auth/test_onboarding.py rename to tests/unit/proxy/auth/test_onboarding.py index 5d173e57cdf..46a48c21353 100644 --- a/tests/test_litellm/proxy/auth/test_onboarding.py +++ b/tests/unit/proxy/auth/test_onboarding.py @@ -632,7 +632,7 @@ async def test_claim_token_rejects_short_password_before_consuming_invite(): @pytest.mark.asyncio @respx.mock -async def test_claim_token_rejects_breached_password_before_consuming_invite(): +async def test_claim_token_rejects_breached_password_before_consuming_invite(httpx_transport): """A password found in the HIBP corpus must be rejected and never stored.""" from litellm.proxy.proxy_server import claim_onboarding_link @@ -666,7 +666,7 @@ async def test_claim_token_rejects_breached_password_before_consuming_invite(): @pytest.mark.asyncio @respx.mock -async def test_claim_token_fails_open_when_hibp_unreachable(): +async def test_claim_token_fails_open_when_hibp_unreachable(httpx_transport): """An HIBP outage must never block onboarding: the claim proceeds.""" from litellm.proxy.proxy_server import claim_onboarding_link diff --git a/tests/test_litellm/proxy/auth/test_organization_budget_enforcement.py b/tests/unit/proxy/auth/test_organization_budget_enforcement.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_organization_budget_enforcement.py rename to tests/unit/proxy/auth/test_organization_budget_enforcement.py diff --git a/tests/test_litellm/proxy/auth/test_password_hashing.py b/tests/unit/proxy/auth/test_password_hashing.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_password_hashing.py rename to tests/unit/proxy/auth/test_password_hashing.py diff --git a/tests/test_litellm/proxy/auth/test_password_policy.py b/tests/unit/proxy/auth/test_password_policy.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_password_policy.py rename to tests/unit/proxy/auth/test_password_policy.py diff --git a/tests/test_litellm/proxy/auth/test_resolvers_exceptions.py b/tests/unit/proxy/auth/test_resolvers_exceptions.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_resolvers_exceptions.py rename to tests/unit/proxy/auth/test_resolvers_exceptions.py diff --git a/tests/test_litellm/proxy/auth/test_resolvers_grants.py b/tests/unit/proxy/auth/test_resolvers_grants.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_resolvers_grants.py rename to tests/unit/proxy/auth/test_resolvers_grants.py diff --git a/tests/test_litellm/proxy/auth/test_resolvers_models.py b/tests/unit/proxy/auth/test_resolvers_models.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_resolvers_models.py rename to tests/unit/proxy/auth/test_resolvers_models.py diff --git a/tests/test_litellm/proxy/auth/test_resolvers_seam.py b/tests/unit/proxy/auth/test_resolvers_seam.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_resolvers_seam.py rename to tests/unit/proxy/auth/test_resolvers_seam.py diff --git a/tests/test_litellm/proxy/auth/test_resolvers_store.py b/tests/unit/proxy/auth/test_resolvers_store.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_resolvers_store.py rename to tests/unit/proxy/auth/test_resolvers_store.py diff --git a/tests/test_litellm/proxy/auth/test_route_checks.py b/tests/unit/proxy/auth/test_route_checks.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_route_checks.py rename to tests/unit/proxy/auth/test_route_checks.py diff --git a/tests/test_litellm/proxy/auth/test_router_override_fallback_auth.py b/tests/unit/proxy/auth/test_router_override_fallback_auth.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_router_override_fallback_auth.py rename to tests/unit/proxy/auth/test_router_override_fallback_auth.py diff --git a/tests/test_litellm/proxy/auth/test_team_grants.py b/tests/unit/proxy/auth/test_team_grants.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_team_grants.py rename to tests/unit/proxy/auth/test_team_grants.py diff --git a/tests/test_litellm/proxy/auth/test_team_member_budget.py b/tests/unit/proxy/auth/test_team_member_budget.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_team_member_budget.py rename to tests/unit/proxy/auth/test_team_member_budget.py diff --git a/tests/test_litellm/proxy/auth/test_unmapped_model_budget_enforcement.py b/tests/unit/proxy/auth/test_unmapped_model_budget_enforcement.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_unmapped_model_budget_enforcement.py rename to tests/unit/proxy/auth/test_unmapped_model_budget_enforcement.py diff --git a/tests/test_litellm/proxy/auth/test_user_api_key_auth.py b/tests/unit/proxy/auth/test_user_api_key_auth_request_flow.py similarity index 100% rename from tests/test_litellm/proxy/auth/test_user_api_key_auth.py rename to tests/unit/proxy/auth/test_user_api_key_auth_request_flow.py diff --git a/tests/test_litellm/proxy/client/cli/autoroute/__init__.py b/tests/unit/proxy/client/__init__.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/autoroute/__init__.py rename to tests/unit/proxy/client/__init__.py diff --git a/tests/test_litellm/proxy/client/cli/__init__.py b/tests/unit/proxy/client/cli/__init__.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/__init__.py rename to tests/unit/proxy/client/cli/__init__.py diff --git a/tests/test_litellm/proxy/policy_engine/__init__.py b/tests/unit/proxy/client/cli/autoroute/__init__.py similarity index 100% rename from tests/test_litellm/proxy/policy_engine/__init__.py rename to tests/unit/proxy/client/cli/autoroute/__init__.py diff --git a/tests/test_litellm/proxy/client/cli/autoroute/test_commands.py b/tests/unit/proxy/client/cli/autoroute/test_commands.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/autoroute/test_commands.py rename to tests/unit/proxy/client/cli/autoroute/test_commands.py diff --git a/tests/test_litellm/proxy/client/cli/autoroute/test_config.py b/tests/unit/proxy/client/cli/autoroute/test_config.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/autoroute/test_config.py rename to tests/unit/proxy/client/cli/autoroute/test_config.py diff --git a/tests/test_litellm/proxy/client/cli/autoroute/test_process.py b/tests/unit/proxy/client/cli/autoroute/test_process.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/autoroute/test_process.py rename to tests/unit/proxy/client/cli/autoroute/test_process.py diff --git a/tests/test_litellm/proxy/client/cli/autoroute/test_wizard.py b/tests/unit/proxy/client/cli/autoroute/test_wizard.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/autoroute/test_wizard.py rename to tests/unit/proxy/client/cli/autoroute/test_wizard.py diff --git a/tests/test_litellm/proxy/client/cli/conftest.py b/tests/unit/proxy/client/cli/conftest.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/conftest.py rename to tests/unit/proxy/client/cli/conftest.py diff --git a/tests/test_litellm/proxy/client/cli/test_agents.py b/tests/unit/proxy/client/cli/test_agents.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/test_agents.py rename to tests/unit/proxy/client/cli/test_agents.py diff --git a/tests/test_litellm/proxy/client/cli/test_auth_commands.py b/tests/unit/proxy/client/cli/test_auth_commands.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/test_auth_commands.py rename to tests/unit/proxy/client/cli/test_auth_commands.py diff --git a/tests/test_litellm/proxy/client/cli/test_claude_settings.py b/tests/unit/proxy/client/cli/test_claude_settings.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/test_claude_settings.py rename to tests/unit/proxy/client/cli/test_claude_settings.py diff --git a/tests/test_litellm/proxy/client/cli/test_codex_settings.py b/tests/unit/proxy/client/cli/test_codex_settings.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/test_codex_settings.py rename to tests/unit/proxy/client/cli/test_codex_settings.py diff --git a/tests/test_litellm/proxy/client/cli/test_config_commands.py b/tests/unit/proxy/client/cli/test_config_commands.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/test_config_commands.py rename to tests/unit/proxy/client/cli/test_config_commands.py diff --git a/tests/test_litellm/proxy/client/cli/test_configure_commands.py b/tests/unit/proxy/client/cli/test_configure_commands.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/test_configure_commands.py rename to tests/unit/proxy/client/cli/test_configure_commands.py diff --git a/tests/test_litellm/proxy/client/cli/test_credentials_commands.py b/tests/unit/proxy/client/cli/test_credentials_commands.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/test_credentials_commands.py rename to tests/unit/proxy/client/cli/test_credentials_commands.py diff --git a/tests/test_litellm/proxy/client/cli/test_debug_commands.py b/tests/unit/proxy/client/cli/test_debug_commands.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/test_debug_commands.py rename to tests/unit/proxy/client/cli/test_debug_commands.py diff --git a/tests/test_litellm/proxy/client/cli/test_encryption_commands.py b/tests/unit/proxy/client/cli/test_encryption_commands.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/test_encryption_commands.py rename to tests/unit/proxy/client/cli/test_encryption_commands.py diff --git a/tests/test_litellm/proxy/client/cli/test_global_options.py b/tests/unit/proxy/client/cli/test_global_options.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/test_global_options.py rename to tests/unit/proxy/client/cli/test_global_options.py diff --git a/tests/test_litellm/proxy/client/cli/test_keys_commands.py b/tests/unit/proxy/client/cli/test_keys_commands.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/test_keys_commands.py rename to tests/unit/proxy/client/cli/test_keys_commands.py diff --git a/tests/test_litellm/proxy/client/cli/test_model_groups_commands.py b/tests/unit/proxy/client/cli/test_model_groups_commands.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/test_model_groups_commands.py rename to tests/unit/proxy/client/cli/test_model_groups_commands.py diff --git a/tests/test_litellm/proxy/client/cli/test_models_commands.py b/tests/unit/proxy/client/cli/test_models_commands.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/test_models_commands.py rename to tests/unit/proxy/client/cli/test_models_commands.py diff --git a/tests/test_litellm/proxy/client/cli/test_pi.py b/tests/unit/proxy/client/cli/test_pi.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/test_pi.py rename to tests/unit/proxy/client/cli/test_pi.py diff --git a/tests/test_litellm/proxy/client/cli/test_pkce_login.py b/tests/unit/proxy/client/cli/test_pkce_login.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/test_pkce_login.py rename to tests/unit/proxy/client/cli/test_pkce_login.py diff --git a/tests/test_litellm/proxy/client/cli/test_statusline_script.py b/tests/unit/proxy/client/cli/test_statusline_script.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/test_statusline_script.py rename to tests/unit/proxy/client/cli/test_statusline_script.py diff --git a/tests/test_litellm/proxy/client/cli/test_up_commands.py b/tests/unit/proxy/client/cli/test_up_commands.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/test_up_commands.py rename to tests/unit/proxy/client/cli/test_up_commands.py diff --git a/tests/test_litellm/proxy/client/cli/test_users_commands.py b/tests/unit/proxy/client/cli/test_users_commands.py similarity index 100% rename from tests/test_litellm/proxy/client/cli/test_users_commands.py rename to tests/unit/proxy/client/cli/test_users_commands.py diff --git a/tests/test_litellm/proxy/client/conftest.py b/tests/unit/proxy/client/conftest.py similarity index 100% rename from tests/test_litellm/proxy/client/conftest.py rename to tests/unit/proxy/client/conftest.py diff --git a/tests/test_litellm/proxy/client/test_chat.py b/tests/unit/proxy/client/test_chat.py similarity index 100% rename from tests/test_litellm/proxy/client/test_chat.py rename to tests/unit/proxy/client/test_chat.py diff --git a/tests/test_litellm/proxy/client/test_client.py b/tests/unit/proxy/client/test_client.py similarity index 100% rename from tests/test_litellm/proxy/client/test_client.py rename to tests/unit/proxy/client/test_client.py diff --git a/tests/test_litellm/proxy/client/test_credentials.py b/tests/unit/proxy/client/test_credentials.py similarity index 100% rename from tests/test_litellm/proxy/client/test_credentials.py rename to tests/unit/proxy/client/test_credentials.py diff --git a/tests/test_litellm/proxy/client/test_http_client.py b/tests/unit/proxy/client/test_http_client.py similarity index 100% rename from tests/test_litellm/proxy/client/test_http_client.py rename to tests/unit/proxy/client/test_http_client.py diff --git a/tests/test_litellm/proxy/client/test_http_commands.py b/tests/unit/proxy/client/test_http_commands.py similarity index 100% rename from tests/test_litellm/proxy/client/test_http_commands.py rename to tests/unit/proxy/client/test_http_commands.py diff --git a/tests/test_litellm/proxy/client/test_keys.py b/tests/unit/proxy/client/test_keys.py similarity index 100% rename from tests/test_litellm/proxy/client/test_keys.py rename to tests/unit/proxy/client/test_keys.py diff --git a/tests/test_litellm/proxy/client/test_model_groups.py b/tests/unit/proxy/client/test_model_groups.py similarity index 100% rename from tests/test_litellm/proxy/client/test_model_groups.py rename to tests/unit/proxy/client/test_model_groups.py diff --git a/tests/test_litellm/proxy/client/test_models.py b/tests/unit/proxy/client/test_models.py similarity index 100% rename from tests/test_litellm/proxy/client/test_models.py rename to tests/unit/proxy/client/test_models.py diff --git a/tests/test_litellm/proxy/client/test_teams.py b/tests/unit/proxy/client/test_teams.py similarity index 100% rename from tests/test_litellm/proxy/client/test_teams.py rename to tests/unit/proxy/client/test_teams.py diff --git a/tests/test_litellm/proxy/client/test_users.py b/tests/unit/proxy/client/test_users.py similarity index 100% rename from tests/test_litellm/proxy/client/test_users.py rename to tests/unit/proxy/client/test_users.py diff --git a/tests/unit/proxy/conftest.py b/tests/unit/proxy/conftest.py index 148751c33f2..1d0a7475db6 100644 --- a/tests/unit/proxy/conftest.py +++ b/tests/unit/proxy/conftest.py @@ -4,12 +4,15 @@ import asyncio import copy import inspect import warnings +from collections.abc import Iterator +from typing import Dict import pytest import litellm import litellm.proxy.proxy_server +from tests.unit.litellm_core_utils.fake_secret_vault import FakeSecretVault # Top-level assignments of these types are the ones importlib.reload(litellm) @@ -148,3 +151,63 @@ def pytest_collection_modifyitems(config, items): # Reorder the items list items[:] = custom_logger_tests + other_tests + + +_PROXY_MODULE_GLOBALS_TO_ISOLATE = ( + "master_key", + "prisma_client", + "llm_router", +) + +_proxy_module_globals_snapshot = pytest.StashKey[Dict[str, object]]() + + +@pytest.hookimpl(hookwrapper=True) +def pytest_runtest_setup(item): + from litellm.proxy import proxy_server + + item.stash[_proxy_module_globals_snapshot] = { + name: vars(proxy_server)[name] + for name in _PROXY_MODULE_GLOBALS_TO_ISOLATE + if name in vars(proxy_server) + } + yield + + +@pytest.hookimpl(hookwrapper=True) +def pytest_runtest_teardown(item, nextitem): + yield + snapshot = item.stash.get(_proxy_module_globals_snapshot, None) + if snapshot is None: + return + from litellm.proxy import proxy_server + + for name in _PROXY_MODULE_GLOBALS_TO_ISOLATE: + if name in snapshot: + setattr(proxy_server, name, snapshot[name]) + elif name in vars(proxy_server): + delattr(proxy_server, name) + + +@pytest.fixture +def secret_vault_factory() -> type[FakeSecretVault]: + return FakeSecretVault + + +@pytest.fixture +def httpx_transport(monkeypatch: pytest.MonkeyPatch) -> Iterator[None]: + monkeypatch.setattr(litellm, "disable_aiohttp_transport", True) + litellm.in_memory_llm_clients_cache.flush_cache() + yield + litellm.in_memory_llm_clients_cache.flush_cache() + + +@pytest.fixture(autouse=True) +def _reset_graceful_shutdown_state(): + from litellm.proxy.shutdown.graceful_shutdown_manager import ( + GracefulShutdownManager, + ) + + GracefulShutdownManager.reset() + yield + GracefulShutdownManager.reset() diff --git a/tests/unit/proxy/hooks/litellm_skills/__init__.py b/tests/unit/proxy/hooks/litellm_skills/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/test_litellm/proxy/hooks/litellm_skills/test_main.py b/tests/unit/proxy/hooks/litellm_skills/test_main.py similarity index 100% rename from tests/test_litellm/proxy/hooks/litellm_skills/test_main.py rename to tests/unit/proxy/hooks/litellm_skills/test_main.py diff --git a/tests/test_litellm/proxy/hooks/test_async_post_call_streaming_iterator_hook.py b/tests/unit/proxy/hooks/test_async_post_call_streaming_iterator_hook.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_async_post_call_streaming_iterator_hook.py rename to tests/unit/proxy/hooks/test_async_post_call_streaming_iterator_hook.py diff --git a/tests/test_litellm/proxy/hooks/test_autorouter_baseline_cache.py b/tests/unit/proxy/hooks/test_autorouter_baseline_cache.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_autorouter_baseline_cache.py rename to tests/unit/proxy/hooks/test_autorouter_baseline_cache.py diff --git a/tests/test_litellm/proxy/hooks/test_batch_enqueued_tokens.py b/tests/unit/proxy/hooks/test_batch_enqueued_tokens.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_batch_enqueued_tokens.py rename to tests/unit/proxy/hooks/test_batch_enqueued_tokens.py diff --git a/tests/test_litellm/proxy/hooks/test_batch_file_validation.py b/tests/unit/proxy/hooks/test_batch_file_validation.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_batch_file_validation.py rename to tests/unit/proxy/hooks/test_batch_file_validation.py diff --git a/tests/test_litellm/proxy/hooks/test_batch_rate_limiter.py b/tests/unit/proxy/hooks/test_batch_rate_limiter.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_batch_rate_limiter.py rename to tests/unit/proxy/hooks/test_batch_rate_limiter.py diff --git a/tests/test_litellm/proxy/hooks/test_dynamic_rate_limiter.py b/tests/unit/proxy/hooks/test_dynamic_rate_limiter.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_dynamic_rate_limiter.py rename to tests/unit/proxy/hooks/test_dynamic_rate_limiter.py diff --git a/tests/test_litellm/proxy/hooks/test_dynamic_rate_limiter_v3.py b/tests/unit/proxy/hooks/test_dynamic_rate_limiter_v3.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_dynamic_rate_limiter_v3.py rename to tests/unit/proxy/hooks/test_dynamic_rate_limiter_v3.py diff --git a/tests/test_litellm/proxy/hooks/test_image_generation_guardrails.py b/tests/unit/proxy/hooks/test_image_generation_guardrails.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_image_generation_guardrails.py rename to tests/unit/proxy/hooks/test_image_generation_guardrails.py diff --git a/tests/test_litellm/proxy/hooks/test_key_management_event_hooks.py b/tests/unit/proxy/hooks/test_key_management_event_hooks.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_key_management_event_hooks.py rename to tests/unit/proxy/hooks/test_key_management_event_hooks.py diff --git a/tests/test_litellm/proxy/hooks/test_max_budget_per_session_limiter.py b/tests/unit/proxy/hooks/test_max_budget_per_session_limiter.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_max_budget_per_session_limiter.py rename to tests/unit/proxy/hooks/test_max_budget_per_session_limiter.py diff --git a/tests/test_litellm/proxy/hooks/test_max_iterations_limiter.py b/tests/unit/proxy/hooks/test_max_iterations_limiter.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_max_iterations_limiter.py rename to tests/unit/proxy/hooks/test_max_iterations_limiter.py diff --git a/tests/test_litellm/proxy/hooks/test_model_max_budget_limiter.py b/tests/unit/proxy/hooks/test_model_max_budget_limiter.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_model_max_budget_limiter.py rename to tests/unit/proxy/hooks/test_model_max_budget_limiter.py diff --git a/tests/test_litellm/proxy/hooks/test_parallel_request_limiter.py b/tests/unit/proxy/hooks/test_parallel_request_limiter.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_parallel_request_limiter.py rename to tests/unit/proxy/hooks/test_parallel_request_limiter.py diff --git a/tests/test_litellm/proxy/hooks/test_parallel_request_limiter_v3.py b/tests/unit/proxy/hooks/test_parallel_request_limiter_v3.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_parallel_request_limiter_v3.py rename to tests/unit/proxy/hooks/test_parallel_request_limiter_v3.py diff --git a/tests/test_litellm/proxy/hooks/test_post_call_failure_hook_integration.py b/tests/unit/proxy/hooks/test_post_call_failure_hook_integration.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_post_call_failure_hook_integration.py rename to tests/unit/proxy/hooks/test_post_call_failure_hook_integration.py diff --git a/tests/test_litellm/proxy/hooks/test_post_call_response_headers_hook.py b/tests/unit/proxy/hooks/test_post_call_response_headers_hook.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_post_call_response_headers_hook.py rename to tests/unit/proxy/hooks/test_post_call_response_headers_hook.py diff --git a/tests/test_litellm/proxy/hooks/test_post_call_streaming_hook_integration.py b/tests/unit/proxy/hooks/test_post_call_streaming_hook_integration.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_post_call_streaming_hook_integration.py rename to tests/unit/proxy/hooks/test_post_call_streaming_hook_integration.py diff --git a/tests/test_litellm/proxy/hooks/test_post_call_success_hook_integration.py b/tests/unit/proxy/hooks/test_post_call_success_hook_integration.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_post_call_success_hook_integration.py rename to tests/unit/proxy/hooks/test_post_call_success_hook_integration.py diff --git a/tests/test_litellm/proxy/hooks/test_prompt_cache_observer.py b/tests/unit/proxy/hooks/test_prompt_cache_observer.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_prompt_cache_observer.py rename to tests/unit/proxy/hooks/test_prompt_cache_observer.py diff --git a/tests/test_litellm/proxy/hooks/test_prompt_injection_detection.py b/tests/unit/proxy/hooks/test_prompt_injection_detection.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_prompt_injection_detection.py rename to tests/unit/proxy/hooks/test_prompt_injection_detection.py diff --git a/tests/test_litellm/proxy/hooks/test_proxy_hooks_init.py b/tests/unit/proxy/hooks/test_proxy_hooks_init.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_proxy_hooks_init.py rename to tests/unit/proxy/hooks/test_proxy_hooks_init.py diff --git a/tests/test_litellm/proxy/hooks/test_proxy_rate_limit_provider_field.py b/tests/unit/proxy/hooks/test_proxy_rate_limit_provider_field.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_proxy_rate_limit_provider_field.py rename to tests/unit/proxy/hooks/test_proxy_rate_limit_provider_field.py diff --git a/tests/test_litellm/proxy/hooks/test_proxy_track_cost_callback.py b/tests/unit/proxy/hooks/test_proxy_track_cost_callback.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_proxy_track_cost_callback.py rename to tests/unit/proxy/hooks/test_proxy_track_cost_callback.py diff --git a/tests/test_litellm/proxy/hooks/test_rate_limiter_toctou.py b/tests/unit/proxy/hooks/test_rate_limiter_toctou.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_rate_limiter_toctou.py rename to tests/unit/proxy/hooks/test_rate_limiter_toctou.py diff --git a/tests/test_litellm/proxy/hooks/test_send_invite_email.py b/tests/unit/proxy/hooks/test_send_invite_email.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_send_invite_email.py rename to tests/unit/proxy/hooks/test_send_invite_email.py diff --git a/tests/test_litellm/proxy/hooks/test_sensitive_data_routing.py b/tests/unit/proxy/hooks/test_sensitive_data_routing.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_sensitive_data_routing.py rename to tests/unit/proxy/hooks/test_sensitive_data_routing.py diff --git a/tests/test_litellm/proxy/hooks/test_tpm_concurrent.py b/tests/unit/proxy/hooks/test_tpm_concurrent.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_tpm_concurrent.py rename to tests/unit/proxy/hooks/test_tpm_concurrent.py diff --git a/tests/test_litellm/proxy/hooks/test_user_management_event_hooks.py b/tests/unit/proxy/hooks/test_user_management_event_hooks.py similarity index 100% rename from tests/test_litellm/proxy/hooks/test_user_management_event_hooks.py rename to tests/unit/proxy/hooks/test_user_management_event_hooks.py diff --git a/tests/unit/proxy/policy_engine/__init__.py b/tests/unit/proxy/policy_engine/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/test_litellm/proxy/policy_engine/test_attachment_registry.py b/tests/unit/proxy/policy_engine/test_attachment_registry.py similarity index 100% rename from tests/test_litellm/proxy/policy_engine/test_attachment_registry.py rename to tests/unit/proxy/policy_engine/test_attachment_registry.py diff --git a/tests/test_litellm/proxy/policy_engine/test_condition_evaluator.py b/tests/unit/proxy/policy_engine/test_condition_evaluator.py similarity index 100% rename from tests/test_litellm/proxy/policy_engine/test_condition_evaluator.py rename to tests/unit/proxy/policy_engine/test_condition_evaluator.py diff --git a/tests/test_litellm/proxy/policy_engine/test_pipeline_executor.py b/tests/unit/proxy/policy_engine/test_pipeline_executor.py similarity index 100% rename from tests/test_litellm/proxy/policy_engine/test_pipeline_executor.py rename to tests/unit/proxy/policy_engine/test_pipeline_executor.py diff --git a/tests/test_litellm/proxy/policy_engine/test_policy_engine_endpoints.py b/tests/unit/proxy/policy_engine/test_policy_engine_endpoints.py similarity index 100% rename from tests/test_litellm/proxy/policy_engine/test_policy_engine_endpoints.py rename to tests/unit/proxy/policy_engine/test_policy_engine_endpoints.py diff --git a/tests/test_litellm/proxy/policy_engine/test_policy_matcher.py b/tests/unit/proxy/policy_engine/test_policy_matcher.py similarity index 100% rename from tests/test_litellm/proxy/policy_engine/test_policy_matcher.py rename to tests/unit/proxy/policy_engine/test_policy_matcher.py diff --git a/tests/test_litellm/proxy/policy_engine/test_policy_resolver.py b/tests/unit/proxy/policy_engine/test_policy_resolver.py similarity index 100% rename from tests/test_litellm/proxy/policy_engine/test_policy_resolver.py rename to tests/unit/proxy/policy_engine/test_policy_resolver.py diff --git a/tests/test_litellm/proxy/policy_engine/test_policy_validator.py b/tests/unit/proxy/policy_engine/test_policy_validator.py similarity index 100% rename from tests/test_litellm/proxy/policy_engine/test_policy_validator.py rename to tests/unit/proxy/policy_engine/test_policy_validator.py diff --git a/tests/test_litellm/proxy/policy_engine/test_policy_versioning.py b/tests/unit/proxy/policy_engine/test_policy_versioning.py similarity index 100% rename from tests/test_litellm/proxy/policy_engine/test_policy_versioning.py rename to tests/unit/proxy/policy_engine/test_policy_versioning.py diff --git a/tests/test_litellm/proxy/policy_engine/test_policy_versioning_e2e.py b/tests/unit/proxy/policy_engine/test_policy_versioning_e2e.py similarity index 100% rename from tests/test_litellm/proxy/policy_engine/test_policy_versioning_e2e.py rename to tests/unit/proxy/policy_engine/test_policy_versioning_e2e.py diff --git a/tests/test_litellm/proxy/policy_engine/test_response_retrieval.py b/tests/unit/proxy/policy_engine/test_response_retrieval.py similarity index 100% rename from tests/test_litellm/proxy/policy_engine/test_response_retrieval.py rename to tests/unit/proxy/policy_engine/test_response_retrieval.py diff --git a/tests/test_litellm/proxy/test_proxy_server.py b/tests/unit/proxy/test_proxy_server_endpoints_and_startup.py similarity index 100% rename from tests/test_litellm/proxy/test_proxy_server.py rename to tests/unit/proxy/test_proxy_server_endpoints_and_startup.py diff --git a/tests/test_litellm/proxy/test_proxy_utils.py b/tests/unit/proxy/test_proxy_utils_model_creation_and_error_logging.py similarity index 100% rename from tests/test_litellm/proxy/test_proxy_utils.py rename to tests/unit/proxy/test_proxy_utils_model_creation_and_error_logging.py