litellm/tests/test_litellm/proxy/db/db_transaction_queue
Tin Chi Lo 52ca688c9d refactor(spend): let the types carry the facts the tests already assert
Three review points, one theme: state that was true in the tests but not
expressed in the code.

`autorouter_savings_spend` was a required key on `BaseDailySpendTransaction`
while every reader coalesces a missing value to zero and the aggregation is
explicitly tested against rows that omit it. Rows queued by a pod on the previous
release, or replayed from the Redis buffer across an upgrade, carry no such key,
so the honest declaration is NotRequired. Requiring it also made every
construction site outside this PR a type error for no gain.

The derived baseline was cached behind a value plus a separate "have we derived
yet" flag, so a baseline of None was indistinguishable from an uncomputed one
until the flag was consulted. `cached_property` already stores None as a real
cached value, so both attributes and the flag collapse into one declaration and
the ambiguity is gone by construction rather than by discipline.

`_baseline_usage` moves the cache-creation tokens into the cached count and drops
the creation charge, which is the whole point of the counterfactual and was
readable only to someone who had absorbed the PR description. It now says so
where it happens.

The pairing test that enumerates additive metrics now unwraps NotRequired, so a
metric declared that way is still covered rather than silently skipped.
2026-07-31 21:57:39 -07:00
..
test_base_update_queue.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_daily_spend_update_queue.py refactor(spend): let the types carry the facts the tests already assert 2026-07-31 21:57:39 -07:00
test_pod_lock_manager.py fix(pod_lock): release cron lock by matching async_set_cache JSON encoding (#30600) 2026-06-17 17:01:04 -07:00
test_redis_update_buffer.py chore: litellm oss staging160626 (#30527) 2026-06-16 18:23:13 -07:00
test_spend_logs_partition_manager.py feat(spend_logs): opt-in native Postgres partitioning for SpendLogs retention (#29466) 2026-06-11 11:02:42 -07:00
test_spend_update_queue.py fix(proxy): avoid in-place mutation in SpendUpdateQueue aggregation (#20876) 2026-02-10 22:36:03 -08:00
test_tool_discovery_queue.py feat(proxy): tool policies - auto-discover tools + policy enforcement guardrail (#22041) 2026-02-24 16:27:06 -08:00