The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test(models): stop the password serialization test matching field-name substrings
Oliver Jensenf9da8a19b680
diff --git a/tests/test_litellm/models/test_models.py b/tests/test_litellm/models/test_models.pyindex aa6449c98dd..02d3a519586 100644--- a/tests/test_litellm/models/test_models.py+++ b/tests/test_litellm/models/test_models.py@@ -93,9 +93,7 @@ class TestCredentials:assert item.credential_values is Nonedef test_create_credential_item_requires_values_or_model_id(self):- with pytest.raises(- ValueError, match="Either credential_values or model_id must be set"- ):+ with pytest.raises(ValueError, match="Either credential_values or model_id must be set"):CreateCredentialItem(credential_name="bad", credential_info={})@@ -113,12 +111,8 @@ class TestModel:assert model.team_public_model_name == "my-gpt4"def test_is_blocked(self):- model_blocked = LiteLLM_ProxyModelTable(- model_id="m1", model_name="test", litellm_params={}, blocked=True- )- model_unblocked = LiteLLM_ProxyModelTable(- model_id="m2", model_name="test", litellm_params={}, blocked=False- )+ model_blocked = LiteLLM_ProxyModelTable(model_id="m1", model_name="test", litellm_params={}, blocked=True)+ model_unblocked = LiteLLM_ProxyModelTable(model_id="m2", model_name="test", litellm_params={}, blocked=False)assert model_blocked.is_blockedassert not model_unblocked.is_blocked@@ -160,9 +154,7 @@ class TestModel:assert model.blocked is Truedef test_team_helpers_none_when_no_model_info(self):- model = LiteLLM_ProxyModelTable(- model_id="m1", model_name="gpt-4", litellm_params={}, model_info=None- )+ model = LiteLLM_ProxyModelTable(model_id="m1", model_name="gpt-4", litellm_params={}, model_info=None)assert model.team_id is Noneassert model.team_public_model_name is None@@ -264,9 +256,7 @@ class TestTeam:assert team.model_max_budget == {"gpt-4": 5.0}def test_cached_team(self):- cached = LiteLLM_TeamTableCachedObj(- team_id="t1", last_refreshed_at=1234567890.0- )+ cached = LiteLLM_TeamTableCachedObj(team_id="t1", last_refreshed_at=1234567890.0)assert cached.last_refreshed_at == 1234567890.0def test_deleted_team(self):@@ -308,6 +298,8 @@ class TestUser:assert user_no_models.has_model_access("any-model")def test_password_hash_excluded_from_serialization(self):+ import json+from litellm.proxy._types import LiteLLM_UserTableWithKeyCountsecret = "$2b$12$abcdefghijklmnopqrstuv"@@ -315,14 +307,12 @@ class TestUser:assert user.password == secretassert "password" not in user.model_dump()- assert "password" not in user.model_dump_json()+ assert "password" not in json.loads(user.model_dump_json())- with_keys = LiteLLM_UserTableWithKeyCount(- user_id="u1", user_email="[email protected]", password=secret, key_count=2- )+ with_keys = LiteLLM_UserTableWithKeyCount(user_id="u1", user_email="[email protected]", password=secret, key_count=2)assert with_keys.password == secretassert "password" not in with_keys.model_dump()- assert "password" not in with_keys.model_dump_json()+ assert "password" not in json.loads(with_keys.model_dump_json())class TestVerificationToken:@@ -443,9 +433,7 @@ class TestEndUserTable:class TestBudgetTableFull:def test_full_adds_server_managed_fields(self):now = datetime.now()- budget = LiteLLM_BudgetTableFull(- budget_id="b1", max_budget=10.0, created_at=now, budget_reset_at=now- )+ budget = LiteLLM_BudgetTableFull(budget_id="b1", max_budget=10.0, created_at=now, budget_reset_at=now)assert budget.created_at == nowassert budget.budget_reset_at == nowassert budget.max_budget == 10.0@@ -457,9 +445,7 @@ class TestBudgetTableFull:class TestTeamMemberTable:def test_tracks_user_within_team(self):- member = LiteLLM_TeamMemberTable(- user_id="u1", team_id="t1", spend=3.0, budget_id="b1", max_budget=5.0- )+ member = LiteLLM_TeamMemberTable(user_id="u1", team_id="t1", spend=3.0, budget_id="b1", max_budget=5.0)assert member.user_id == "u1"assert member.team_id == "t1"assert member.spend == 3.0@@ -549,9 +535,7 @@ class TestSpendLogs:assert log.updated_at == updated_atdef test_error_logs_creation(self):- log = LiteLLM_ErrorLogs(- request_id="r1", startTime=None, endTime=None, status_code="500"- )+ log = LiteLLM_ErrorLogs(request_id="r1", startTime=None, endTime=None, status_code="500")assert log.request_id == "r1"assert log.status_code == "500"@@ -569,9 +553,7 @@ class TestManagedTables:def test_managed_object_table_requires_purpose(self):with pytest.raises(ValidationError):- LiteLLM_ManagedObjectTable(- unified_object_id="o1", model_object_id="m1", file_object={}- )+ LiteLLM_ManagedObjectTable(unified_object_id="o1", model_object_id="m1", file_object={})def test_managed_vector_stores_table(self):table = LiteLLM_ManagedVectorStoresTable(