mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
test(repositories): lock in UserRepository JSON column decoding
Covers the columns UserRepository._to_model decodes so a narrower or wider column set fails instead of silently changing what callers read back.
This commit is contained in:
parent
c0cab45350
commit
2258dc08aa
1 changed files with 22 additions and 0 deletions
|
|
@ -1905,6 +1905,28 @@ class TestUserRepositoryExtended:
|
|||
)
|
||||
assert updated.user_email == "new@example.com"
|
||||
|
||||
@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": "json@example.com",
|
||||
"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 == "json@example.com"
|
||||
assert user.user_role == '{"not": "json"}'
|
||||
|
||||
|
||||
class TestProjectRepositoryExtended:
|
||||
@pytest.fixture
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue