litellm/tests
joshua-berri f94c79290c
feat(ui): show an optional currency estimate on the Usage spend card (#51979)
* feat(ui): show the usage spend total in another currency at ECB reference rates

Adds GET /get/reference_exchange_rates, which returns the current ECB
reference rates as USD per unit for every feed currency. It refreshes at
most once a day under a lock, keeps fresh rates when a refresh fails and
answers 503 instead of serving rates older than seven days.

The usage overview's spend card gets a Spend display selector. It asks for
rates only once opened and then shows an estimated amount with the rate date
under the unchanged USD total. Every other figure stays in USD.

* fix(ui): fall back to USD when spend display rates stop being usable

The selector now shows USD whenever no estimate can be shown, so a failed
refetch never leaves EUR selected beside a USD-only notice, and an opened
selector refreshes its rates hourly. The endpoint gets its HTTP client
inside the async fetch so the client belongs to the serving event loop.

* fix(proxy): import the ECB rates endpoint HTTP client helper at module level

Binds get_async_httpx_client at import so its type is known. The client is
still built inside the awaited fetch on the serving event loop.

* fix(proxy): fetch display rates with a short-lived handler closed after each refresh

Builds an AsyncHTTPHandler inside the refresh fetch and closes it when the
fetch ends, and drops the descriptive comment on the spend display component.

* chore(ui): regenerate API types for the reference exchange rates endpoint

* fix(proxy): use the cached async client factory for display rate refreshes

Direct AsyncHTTPHandler construction fails the async client check, so the
refresh fetch goes back to get_async_httpx_client, called inside the awaited
fetch, with a named type suppression for the factory's untyped params.

* fix(ui): tidy spend display helper, hook options and fallback test

Groups the rate snapshot into one estimatedSpend argument, names the rates
query options, names the missing-estimate condition, and waits for the
unavailable notice before asserting the USD fallback.

* chore(ui): drop a restating comment on the spend estimate helper

* test(proxy): prove concurrent first rate requests share one ECB fetch

* fix(proxy): wait a minute before retrying a failed display rate refresh

A failed ECB refresh left rates due, so every request after it waited on
the lock and fetched again, and N queued callers paid N timeouts during an
outage. The endpoint now skips refreshing for 60 seconds after a failed
attempt, serving held rates or a 503, and retries on the first request
after that. Concurrent waiters share the failed attempt. Also drops the
usd_rates docstring.

* fix(ui): retry unavailable currency estimates on reopen

* refactor(ui): name the currency selector open handler

* style(ui): format currency selector props

---------

Co-authored-by: Joshua Valluru <326636767+joshua-berri@users.noreply.github.com>
2026-11-16 16:00:20 -08:00
..
_support feat(db): emit DB service events from native operations (#49810) 2026-11-14 15:28:10 -08:00
audio_tests feat(vertex-ai)!: support gemini 3.1 flash tts (#31915) 2026-10-21 04:18:42 +00:00
base_sdk_tests chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
basic_proxy_startup_tests feat(docker)!: one shipped image and one entrypoint beside the Dockerfile (#43332) 2026-11-10 18:32:16 -08:00
benchmarks fix(proxy): count the request's tool_choice on the token count routes (#51133) 2026-11-14 07:53:27 -05:00
code_coverage_tests fix(proxy): rewrite batch JSONL alias rows to the deployment model on model-routed uploads (#51843) 2026-11-16 15:12:52 -08:00
documentation_tests chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
e2e test: update four stale integration and UI tests for intended behavior changes (#52108) 2026-11-16 13:20:21 -08:00
e2e_harness test(e2e): drop two batch waits that never finish in time (#51882) 2026-11-14 21:41:43 -08:00
fixtures test: migrate tests/llm_translation into unit, integration and e2e tiers (#45759) 2026-10-11 07:58:53 +00:00
harness_e2e fix(harness): set PWD to the working directory of local sandbox commands (#47530) 2026-10-20 20:06:11 +00:00
integration feat(alerts): report observed Anthropic cache misses as advisories (#51973) 2026-11-16 15:36:07 -08:00
rust-python-harness feat(messages): serve azure ai foundry messages on rust only (#51721) 2026-11-14 13:40:38 -08:00
test_litellm_rust feat(messages): serve bedrock invoke messages on rust only (#51330) 2026-11-15 16:58:31 -08:00
typing chore: move config and docs off the repo root (#50966) 2026-11-11 18:29:35 -08:00
unit feat(ui): show an optional currency estimate on the Usage spend card (#51979) 2026-11-16 16:00:20 -08:00
windows_tests ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
__init__.py
_fake_openai_endpoint_server.py
_flush_vcr_cache.py
_live_test_helpers.py
_master_key.py
_module_state.py ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
_openai_record_replay_proxy.py
_process_helpers.py
_vcr_conftest_common.py ci: remove CircleCI (#50950) 2026-11-11 15:38:27 -08:00
_vcr_redis_persister.py
_wait_helpers.py
_ws_vcr.py
AGENTS.md docs(agents): ban semicolons and colons in human-facing text (#45684) 2026-10-09 16:36:32 -07:00
capturing_transport.py
eval_swe_bench.py
fake_openai_endpoint.py
gettysburg.wav
large_text.py
openai_batch_completions.jsonl
pyrightconfig.json
README.MD
test_logging.conf
test_rust_python_harness.py
VCR_TESTING.md test: migrate tests/llm_translation into unit, integration and e2e tiers (#45759) 2026-10-11 07:58:53 +00:00
white_100x100.png

In total litellm runs 1000+ tests

[02/20/2025] Update:

To make it easier to contribute and map what behavior is tested,

we've started mapping the litellm directory in tests/unit

This folder can only run mock tests.