mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-16 09:22:22 +00:00
* refactor(typing): clear basedpyright Any errors (wave 1) * refactor(typing): clear basedpyright Any errors (wave 2) * refactor(typing): clear basedpyright Any errors (wave 3) * refactor(typing): clear basedpyright Any errors (wave 4) * refactor(typing): clear basedpyright Any errors (wave 5) * refactor(typing): clear basedpyright Any errors (wave 6) * fix(typing): keep the cached-plan fallback's direct query_first calls so span naming resolves * fix(logging): keep callbacks running when litellm_params is a params model should_run_callback and the sync success and failure handlers read litellm_params through any object with a get method again, as they did before this branch, so a logging hook that returns a GenericLiteLLMParams no longer stops sync logging for that request Adds behavior tests for the changed lines codecov listed as not run * fix: read the regional uplift for every data residency again and reuse one dict TypeAdapter The typed lookup only read the eu and us multipliers, so a deployment that set regional_processing_uplift_multiplier_fedramp stopped applying it. /model/update and the model write paths now share one module-level TypeAdapter instead of building one per call. * fix: bill regional uplift multipliers float() accepts, bytes included * fix: raise the in operator's own error from one shared json_contains, and name the bad uplift type
61 lines
1.9 KiB
Python
61 lines
1.9 KiB
Python
import time
|
|
|
|
import pytest
|
|
import requests
|
|
import responses
|
|
|
|
from litellm.proxy.client.exceptions import UnauthorizedError
|
|
from litellm.proxy.client.teams import TeamsManagementClient
|
|
|
|
|
|
def test_list_gives_up_at_the_timeout_instead_of_hanging(hanging_server):
|
|
"""
|
|
A proxy that accepts the connection but never answers used to pin the caller's
|
|
process forever, since the request carried no timeout at all.
|
|
"""
|
|
client = TeamsManagementClient(base_url=hanging_server, api_key="sk-test", timeout=1)
|
|
|
|
started = time.monotonic()
|
|
with pytest.raises(requests.exceptions.Timeout):
|
|
client.list()
|
|
|
|
assert time.monotonic() - started < 10
|
|
|
|
|
|
@responses.activate
|
|
def test_list_v2_sends_filters_and_returns_the_page():
|
|
client = TeamsManagementClient(base_url="http://localhost:8000", api_key="sk-test")
|
|
page = {"teams": [{"team_id": "team-1"}], "total": 1, "page": 2, "page_size": 5, "total_pages": 1}
|
|
responses.add(
|
|
responses.GET,
|
|
"http://localhost:8000/v2/team/list",
|
|
json=page,
|
|
status=200,
|
|
match=[
|
|
responses.matchers.query_param_matcher(
|
|
{
|
|
"page": "2",
|
|
"page_size": "5",
|
|
"sort_order": "desc",
|
|
"user_id": "user-1",
|
|
"team_alias": "search",
|
|
"sort_by": "created_at",
|
|
}
|
|
)
|
|
],
|
|
)
|
|
|
|
result = client.list_v2(
|
|
user_id="user-1", team_alias="search", page=2, page_size=5, sort_by="created_at", sort_order="desc"
|
|
)
|
|
|
|
assert result == page
|
|
|
|
|
|
@responses.activate
|
|
def test_list_v2_unauthorized_error():
|
|
client = TeamsManagementClient(base_url="http://localhost:8000", api_key="sk-bad")
|
|
responses.add(responses.GET, "http://localhost:8000/v2/team/list", status=401, json={"error": "Unauthorized"})
|
|
|
|
with pytest.raises(UnauthorizedError):
|
|
client.list_v2()
|