mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-11 03:38:38 +00:00
test(proxy): assert negative spend is allowed (one-time grant use-case)
Negative spend is intentionally permitted so admins can grant a team member extra allowance for the current budget period only, without raising the recurring budget ceiling. Cover it in validate_finite_spend and via the /team/member_update spend-reset test.
This commit is contained in:
parent
cc81bc9a77
commit
d5d8cd4fe1
1 changed files with 9 additions and 4 deletions
|
|
@ -169,7 +169,12 @@ async def test_team_member_update_spend_writes_membership_and_invalidates(
|
|||
invalidate = AsyncMock()
|
||||
monkeypatch.setattr(proxy_server, "_invalidate_spend_counter", invalidate)
|
||||
|
||||
data, request, auth = _member_update_request(spend=0.0)
|
||||
# Use a negative spend: this also implicitly validates that negative spend
|
||||
# is allowed, which is desirable. Admins may grant a team member extra
|
||||
# allowance for the current budget period only (a one-time spend grant)
|
||||
# without raising the recurring budget ceiling. Future changes should
|
||||
# continue allowing negative spend counters.
|
||||
data, request, auth = _member_update_request(spend=-25.0)
|
||||
|
||||
response = await team_member_update(data, request, auth)
|
||||
|
||||
|
|
@ -178,12 +183,12 @@ async def test_team_member_update_spend_writes_membership_and_invalidates(
|
|||
assert kwargs["where"] == {
|
||||
"user_id_team_id": {"user_id": "user-1", "team_id": "team-1234"}
|
||||
}
|
||||
assert kwargs["data"]["update"] == {"spend": 0.0}
|
||||
assert kwargs["data"]["create"]["spend"] == 0.0
|
||||
assert kwargs["data"]["update"] == {"spend": -25.0}
|
||||
assert kwargs["data"]["create"]["spend"] == -25.0
|
||||
invalidate.assert_awaited_once_with(
|
||||
counter_key="spend:team_member:user-1:team-1234"
|
||||
)
|
||||
assert response.spend == 0.0
|
||||
assert response.spend == -25.0
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue