test(proxy): stay within the test-quality TQ001/TQ008 budget

The two new cancel-path tests pushed TQ001 (an assertion-free test) and
TQ008 (patching a litellm internal) over their limits. Added a real
assertion to the cancellation test (finalized stays False, since
absorbing a second CancelledError isn't the failure path) and
test-quality-ok annotations on the three patch() calls, matching this
file's existing pattern for module functions with no DI seam.
This commit is contained in:
Abhyuday 2026-09-14 16:41:09 -04:00
parent e9836165d7
commit 90a6e8d423

View file

@ -2799,13 +2799,16 @@ async def test_release_budget_reservation_on_cancel_swallows_a_second_cancellati
"finalized": False,
"input_cost": 0.5,
}
with patch(
with patch( # test-quality-ok: reconcile_budget_reservation is a module function, no DI seam for this test
"litellm.proxy.spend_tracking.budget_reservation.reconcile_budget_reservation",
new=AsyncMock(side_effect=asyncio.CancelledError()),
):
# must return without raising
# must return without raising, and without taking the finalize-on-failure path either:
# a second cancellation isn't a failure, it's the reconcile still running in the background
await release_budget_reservation_on_cancel(reservation)
assert reservation["finalized"] is False
@pytest.mark.asyncio
async def test_release_budget_reservation_on_cancel_swallows_invalidate_failure_after_every_retry_fails():
@ -2818,10 +2821,10 @@ async def test_release_budget_reservation_on_cancel_swallows_invalidate_failure_
"finalized": False,
"input_cost": 0.5,
}
with patch(
with patch( # test-quality-ok: reconcile_budget_reservation is a module function, no DI seam for this test
"litellm.proxy.spend_tracking.budget_reservation.reconcile_budget_reservation",
new=AsyncMock(side_effect=RuntimeError("redis down")),
), patch(
), patch( # test-quality-ok: invalidate_budget_reservation_counters is a module function, no DI seam for this test
"litellm.proxy.spend_tracking.budget_reservation.invalidate_budget_reservation_counters",
new=AsyncMock(side_effect=RuntimeError("redis still down")),
):