Skip to content

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]

test(repositories): lock in UserRepository JSON column decoding

mateo-berri2258dc08aaa6
diff --git a/tests/test_litellm/repositories/test_repositories.py b/tests/test_litellm/repositories/test_repositories.py
index c923b722991..8253308f393 100644
--- a/tests/test_litellm/repositories/test_repositories.py
+++ b/tests/test_litellm/repositories/test_repositories.py
@@ -1905,6 +1905,28 @@ class TestUserRepositoryExtended:
)
assert updated.user_email == "[email protected]"
+ @pytest.mark.asyncio
+ async def test_find_by_id_decodes_only_the_json_encoded_columns(self, repo):
+ repo._prisma_client.db.litellm_usertable._records["user-json"] = {
+ "user_id": "user-json",
+ "user_email": "[email protected]",
+ "user_role": '{"not": "json"}',
+ "teams": [],
+ "models": [],
+ "metadata": '{"department": "engineering"}',
+ "model_spend": '{"gpt-4": 10.5}',
+ "model_max_budget": '{"gpt-4": 100.0}',
+ }
+
+ user = await repo.find_by_id("user-json")
+
+ assert user is not None
+ assert user.metadata == {"department": "engineering"}
+ assert user.model_spend == {"gpt-4": 10.5}
+ assert user.model_max_budget == {"gpt-4": 100.0}
+ assert user.user_email == "[email protected]"
+ assert user.user_role == '{"not": "json"}'
+
class TestProjectRepositoryExtended:
@pytest.fixture