From 3926e74e9df086f1c77bb1745da672de25d60934 Mon Sep 17 00:00:00 2001 From: yassin Date: Fri, 18 Sep 2026 01:28:49 +0000 Subject: [PATCH] test(proxy): lock plain member updates to the merge-patch contract without a team default snapshot Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../test_upsert_budget_membership.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_litellm/proxy/common_utils/test_upsert_budget_membership.py b/tests/test_litellm/proxy/common_utils/test_upsert_budget_membership.py index e17a1a287bf..cabf5e24933 100644 --- a/tests/test_litellm/proxy/common_utils/test_upsert_budget_membership.py +++ b/tests/test_litellm/proxy/common_utils/test_upsert_budget_membership.py @@ -280,6 +280,29 @@ async def test_create_from_temp_pair_skips_zero_team_default_cap(mock_tx, fake_u mock_tx.litellm_teammembership.upsert.assert_awaited_once() +@pytest.mark.asyncio +async def test_create_from_plain_patch_does_not_snapshot_team_default(mock_tx, fake_user): + mock_tx.litellm_budgettable.find_unique = AsyncMock( + return_value=budget_row(budget_id="team-default-budget-1", max_budget=0.4, rpm_limit=10) + ) + await _upsert_budget_and_membership( + mock_tx, + team_id="team-default", + user_id="user-unlinked", + existing_budget_id=None, + user_api_key_dict=fake_user, + budget_patch={"tpm_limit": 500}, + team_default_budget_id="team-default-budget-1", + ) + + mock_tx.litellm_budgettable.find_unique.assert_not_awaited() + data = mock_tx.litellm_budgettable.create.await_args.kwargs["data"] + assert data["tpm_limit"] == 500 + assert "max_budget" not in data + assert "rpm_limit" not in data + mock_tx.litellm_teammembership.upsert.assert_awaited_once() + + # TEST: clone-on-write when the membership still points at the team's shared # default budget. Editing this member must fork a private budget instead of # mutating the shared row, and cloning a duration must seed a fresh reset time.