litellm/tests/unit/repositories
Mateo Wang ac08eb5663
fix: make scheduled key, user, and team spend resets idempotent (#50298)
* fix: make scheduled spend resets idempotent

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test: cover reset roundoff with shared Redis workers

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test: isolate reset workers and type raw adapters

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix: keep updated_at moving on zero-spend budget resets

* fix: never leave spend below zero after a budget reset

* fix(proxy): keep the stored budget reset time when budget_duration is resent unchanged

Key, user, and team updates recomputed budget_reset_at whenever the body carried budget_duration, and the Admin UI key form sends it on every save. Under the guarded reset, a resend during a sweep skipped that period's reset, and a resend after the boundary skipped it on main too. An unchanged duration now keeps the stored reset time

* fix(proxy): keep a resent budget reset time only once it is due

A save that resends the same budget_duration keeps the stored reset time
only when that time has already passed, so the scheduled sweep still
resets the period it is due for. A row that is not due yet realigns its
reset time on save, the same as before.

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-09 22:21:43 -08:00
..
__init__.py test: add __init__.py to new tests/unit packages 2026-09-20 12:36:13 +00:00
test_chunked_in.py ci: fail on new unbounded SQL IN lists and add a Prisma chunking helper (#42629) 2026-09-26 13:40:44 -07:00
test_daily_activity_repository.py feat(usage): split customer spend by the key's current team (#50764) 2026-11-09 19:35:31 -08:00
test_daily_activity_sql.py fix!: retain unattributed daily activity across reports and exports (#48925) 2026-10-29 09:39:49 -07:00
test_database.py refactor(proxy): inject database repositories through per-repository dependencies (#48507) 2026-10-30 22:57:54 +00:00
test_gateway_activity_repository.py refactor(proxy): inject gateway activity through a typed repository (#49116) 2026-10-30 16:25:11 -07:00
test_plugin_publication.py feat(skills): add sortable Skills Hub catalog and publication audit (#50195) 2026-11-06 00:57:33 +00:00
test_plugin_upload_repository.py feat(skills): show download counts and downloader history (#50165) 2026-11-05 05:25:08 -08:00
test_repositories.py refactor(proxy): inject deployment warning ignores through repositories (#48592) 2026-10-30 22:57:55 +00:00
test_skill_submission_repository.py feat(skills): add sortable Skills Hub catalog and publication audit (#50195) 2026-11-06 00:57:33 +00:00
test_spend_log_insert.py feat(accounting): add opt-in SpendLogs ledger (#49856) 2026-11-04 17:49:15 -08:00
test_unit_of_work.py fix: make scheduled key, user, and team spend resets idempotent (#50298) 2026-11-09 22:21:43 -08:00