mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-12 08:42:18 +00:00
test(proxy): cover config precedence branches
This commit is contained in:
parent
ce4a8b0f34
commit
bae25fee6a
1 changed files with 44 additions and 0 deletions
|
|
@ -2401,6 +2401,23 @@ def test_ConfigGeneralSettings_rejects_invalid_config_source_of_truth():
|
|||
ConfigGeneralSettings.model_validate({"config_source_of_truth": "invalid"})
|
||||
|
||||
|
||||
def test_ProxyConfig__record_deployed_config_accepts_enum_source():
|
||||
pc = ProxyConfig()
|
||||
|
||||
pc._record_deployed_config(
|
||||
{"general_settings": {"config_source_of_truth": ConfigSourceOfTruth.CONFIG_FILE}}
|
||||
)
|
||||
|
||||
assert pc._config_source_of_truth is ConfigSourceOfTruth.CONFIG_FILE
|
||||
|
||||
|
||||
def test_ProxyConfig__record_deployed_config_rejects_non_string_source():
|
||||
pc = ProxyConfig()
|
||||
|
||||
with pytest.raises(ValueError, match="config_source_of_truth"):
|
||||
pc._record_deployed_config({"general_settings": {"config_source_of_truth": 1}})
|
||||
|
||||
|
||||
def test_ProxyConfig__update_config_fields_config_file_wins_conflicts():
|
||||
pc = ProxyConfig()
|
||||
pc._record_deployed_config({"general_settings": {"config_source_of_truth": "config_file"}})
|
||||
|
|
@ -2449,6 +2466,33 @@ def test_ProxyConfig__update_config_fields_config_file_env_wins_case_insensitive
|
|||
assert os.environ["DB_ONLY"] == "database-only"
|
||||
|
||||
|
||||
def test_ProxyConfig__update_config_fields_config_file_applies_safe_litellm_settings(monkeypatch):
|
||||
pc = ProxyConfig()
|
||||
pc._record_deployed_config({"general_settings": {"config_source_of_truth": "config_file"}})
|
||||
monkeypatch.setattr(litellm, "max_ui_session_budget", 0.0)
|
||||
|
||||
out = pc._update_config_fields(
|
||||
current_config={"litellm_settings": {"max_ui_session_budget": 10.0}},
|
||||
param_name="litellm_settings",
|
||||
db_param_value={"max_ui_session_budget": 20.0, "db_only": True},
|
||||
)
|
||||
|
||||
assert out["litellm_settings"] == {"max_ui_session_budget": 10.0, "db_only": True}
|
||||
assert litellm.max_ui_session_budget == 10.0
|
||||
|
||||
|
||||
def test_ProxyConfig__update_config_fields_database_replaces_mismatched_value_types():
|
||||
pc = ProxyConfig()
|
||||
|
||||
out = pc._update_config_fields(
|
||||
current_config={"router_settings": {"timeout": 10}},
|
||||
param_name="router_settings",
|
||||
db_param_value=["database-value"],
|
||||
)
|
||||
|
||||
assert out["router_settings"] == ["database-value"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_ProxyConfig_get_config_reads_source_before_database_merge(monkeypatch):
|
||||
from litellm.proxy import proxy_server
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue