From 15ae7bff5666dfea57cbd83a49ab0d3f4ed027f2 Mon Sep 17 00:00:00 2001 From: Miguel Armenta Date: Wed, 12 Aug 2026 15:28:33 -0500 Subject: [PATCH] test(proxy): run precedence coverage in proxy shard --- .../proxy/proxy_server/test_lifecycle.py | 59 ++++++++++++++++++ tests/test_litellm/proxy/test_proxy_server.py | 60 ------------------- 2 files changed, 59 insertions(+), 60 deletions(-) diff --git a/tests/test_litellm/proxy/proxy_server/test_lifecycle.py b/tests/test_litellm/proxy/proxy_server/test_lifecycle.py index 40ca7e3a64e..390cb728062 100644 --- a/tests/test_litellm/proxy/proxy_server/test_lifecycle.py +++ b/tests/test_litellm/proxy/proxy_server/test_lifecycle.py @@ -770,6 +770,65 @@ def test_proxy_startup_event_warns_for_global_budget_without_database(): ) +@pytest.mark.asyncio +async def test_startup_keeps_config_file_coordination_redis_when_authoritative(): + persisted_settings = AsyncMock(return_value={"host": "database-redis"}) + with ( + patch.object( + ps.proxy_config, + "config_file_general_setting_is_authoritative", + return_value=True, + ), + patch.object( + ps, + "get_persisted_coordination_redis_settings", + persisted_settings, + ), + ): + result = await ProxyStartupEvent._init_coordination_redis_from_db( + litellm_settings={}, + llm_router=None, + ) + + assert result is None + persisted_settings.assert_not_awaited() + + +@pytest.mark.asyncio +async def test_store_model_in_db_config_file_false_blocks_database_override(): + from litellm.proxy.utils import ProxyLogging + + mock_prisma_client = MagicMock() + mock_db_record = MagicMock() + mock_db_record.param_value = {"store_model_in_db": True} + mock_prisma_client.db.litellm_config.find_first = AsyncMock(return_value=mock_db_record) + mock_proxy_logging = MagicMock(spec=ProxyLogging) + mock_proxy_logging.slack_alerting_instance = MagicMock() + mock_proxy_logging.db_spend_update_writer = MagicMock() + mock_proxy_config = MagicMock() + mock_proxy_config.add_deployment = AsyncMock() + mock_proxy_config.init_mcp_servers_from_db = AsyncMock() + mock_proxy_config.config_file_general_setting_is_authoritative = MagicMock(return_value=True) + + with ( + patch.object(ps, "proxy_config", mock_proxy_config), + patch.object(ps, "store_model_in_db", False), + patch.object(ps, "get_secret_bool", return_value=False), + ): + await ProxyStartupEvent.initialize_scheduled_background_jobs( + general_settings={}, + prisma_client=mock_prisma_client, + proxy_budget_rescheduler_min_time=1, + proxy_budget_rescheduler_max_time=2, + proxy_batch_write_at=5, + proxy_logging_obj=mock_proxy_logging, + ) + + assert ps.store_model_in_db is False + mock_prisma_client.db.litellm_config.find_first.assert_not_awaited() + mock_proxy_config.add_deployment.assert_not_awaited() + + # --------------------------------------------------------------------------- # _initialize_slack_alerting_jobs — spend-report pod locking (issue #14809) # --------------------------------------------------------------------------- diff --git a/tests/test_litellm/proxy/test_proxy_server.py b/tests/test_litellm/proxy/test_proxy_server.py index 05b2f9da171..1fd9ebbc67c 100644 --- a/tests/test_litellm/proxy/test_proxy_server.py +++ b/tests/test_litellm/proxy/test_proxy_server.py @@ -7037,42 +7037,6 @@ async def test_store_model_in_db_db_override_when_config_false(): assert mock_proxy_config.get_credentials.call_count == 1 -@pytest.mark.asyncio -async def test_store_model_in_db_config_file_false_blocks_database_override(): - from litellm.proxy.proxy_server import ProxyStartupEvent - from litellm.proxy.utils import ProxyLogging - - mock_prisma_client = MagicMock() - mock_db_record = MagicMock() - mock_db_record.param_value = {"store_model_in_db": True} - mock_prisma_client.db.litellm_config.find_first = AsyncMock(return_value=mock_db_record) - mock_proxy_logging = MagicMock(spec=ProxyLogging) - mock_proxy_logging.slack_alerting_instance = MagicMock() - mock_proxy_logging.db_spend_update_writer = MagicMock() - mock_proxy_config = AsyncMock() - mock_proxy_config.config_file_general_setting_is_authoritative = MagicMock(return_value=True) - - with ( - patch("litellm.proxy.proxy_server.proxy_config", mock_proxy_config), - patch("litellm.proxy.proxy_server.store_model_in_db", False), - patch("litellm.proxy.proxy_server.get_secret_bool", return_value=False), - ): - await ProxyStartupEvent.initialize_scheduled_background_jobs( - general_settings={}, - prisma_client=mock_prisma_client, - proxy_budget_rescheduler_min_time=1, - proxy_budget_rescheduler_max_time=2, - proxy_batch_write_at=5, - proxy_logging_obj=mock_proxy_logging, - ) - - import litellm.proxy.proxy_server as ps - - assert ps.store_model_in_db is False - mock_prisma_client.db.litellm_config.find_first.assert_not_awaited() - mock_proxy_config.add_deployment.assert_not_awaited() - - @pytest.mark.asyncio async def test_store_model_in_db_db_check_skipped_when_already_true(monkeypatch): """ @@ -10592,30 +10556,6 @@ async def test_startup_applies_coordination_redis_saved_in_database(): assert fresh_config_cache.redis_cache is result -@pytest.mark.asyncio -async def test_startup_keeps_config_file_coordination_redis_when_authoritative(): - persisted_settings = AsyncMock(return_value={"host": "database-redis"}) - with ( - patch.object( - proxy_server_module.proxy_config, - "config_file_general_setting_is_authoritative", - return_value=True, - ), - patch.object( - proxy_server_module, - "get_persisted_coordination_redis_settings", - persisted_settings, - ), - ): - result = await proxy_server_module.ProxyStartupEvent._init_coordination_redis_from_db( - litellm_settings={}, - llm_router=None, - ) - - assert result is None - persisted_settings.assert_not_awaited() - - @pytest.mark.asyncio async def test_startup_ignores_database_coordination_redis_without_connection_target(): """A persisted block with no host/url/cluster/sentinel must be ignored rather