mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-13 08:52:02 +00:00
Merge pull request #50091 from BerriAI/litellm_test_26a1e4
test: fix stale unit tests on 1.108 LTS
This commit is contained in:
commit
ba5b54f50c
3 changed files with 21 additions and 30 deletions
|
|
@ -860,35 +860,6 @@ async def test_allowed_routes_admin(
|
|||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_team_cache_update_called():
|
||||
import litellm
|
||||
from litellm.proxy.proxy_server import user_api_key_cache
|
||||
|
||||
# Use setattr to replace the method on the user_api_key_cache object
|
||||
cache = DualCache()
|
||||
|
||||
setattr(
|
||||
litellm.proxy.proxy_server,
|
||||
"user_api_key_cache",
|
||||
cache,
|
||||
)
|
||||
|
||||
with patch.object(cache, "async_batch_get_cache", new=AsyncMock(return_value=[None])) as mock_call_cache:
|
||||
# Call the function under test
|
||||
await litellm.proxy.proxy_server.update_cache(
|
||||
token=None,
|
||||
user_id=None,
|
||||
end_user_id=None,
|
||||
team_id="1234",
|
||||
response_cost=20,
|
||||
parent_otel_span=None,
|
||||
) # type: ignore
|
||||
|
||||
await asyncio.sleep(3)
|
||||
mock_call_cache.assert_awaited_once_with(keys=["team_id:1234"], parent_otel_span=None, throttle_redis=False)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def public_jwt_key():
|
||||
import json
|
||||
|
|
|
|||
|
|
@ -4749,7 +4749,8 @@ def test_reapply_runtime_registrations_replays_register_model_overrides(
|
|||
# installed would make this depend on when that happens.
|
||||
monkeypatch.setattr(litellm_utils._LiveDeploymentReplay, "callback", None)
|
||||
|
||||
saved_model_cost = litellm.model_cost
|
||||
saved_model_cost: Final = litellm.model_cost
|
||||
monkeypatch.setattr(litellm, "model_cost", dict(saved_model_cost))
|
||||
try:
|
||||
litellm.register_model(
|
||||
model_cost={
|
||||
|
|
|
|||
|
|
@ -224,9 +224,20 @@ def test_regional_bedrock_alias_requires_canonical_converse_metadata(
|
|||
_enforce_bedrock_converse_models(model_cost, ())
|
||||
|
||||
|
||||
GOVCLOUD_LAGGING_CAPABILITIES: Final = frozenset({"supports_bedrock_native_structured_output"})
|
||||
|
||||
|
||||
def _govcloud_may_lag(model_key: str, capability: str) -> bool:
|
||||
is_govcloud: Final = model_key.startswith("us-gov.") or any(
|
||||
part.startswith("us-gov-") for part in model_key.split("/")
|
||||
)
|
||||
return is_govcloud and capability in GOVCLOUD_LAGGING_CAPABILITIES
|
||||
|
||||
|
||||
def test_get_model_info_bedrock_models():
|
||||
"""
|
||||
Check for drift in base model info for bedrock models and regional model info for bedrock models.
|
||||
GovCloud regions may lag their commercial base on Bedrock native structured output, never lead it.
|
||||
"""
|
||||
from litellm.llms.bedrock.common_utils import BedrockModelInfo
|
||||
|
||||
|
|
@ -261,6 +272,9 @@ def test_get_model_info_bedrock_models():
|
|||
assert (
|
||||
base_model_key in v
|
||||
), f"{base_model_key} is not in model cost map for {k}"
|
||||
if _govcloud_may_lag(k, base_model_key):
|
||||
assert base_model_value or not v[base_model_key], f"{base_model_key} is on {k} but not its base"
|
||||
continue
|
||||
assert (
|
||||
v[base_model_key] == base_model_value
|
||||
), f"{base_model_key} is not equal to {base_model_value} for model {k}"
|
||||
|
|
@ -297,6 +311,8 @@ def test_get_model_info_bedrock_cross_region_capability_parity():
|
|||
"""
|
||||
Cross-region inference profiles carry litellm_provider "bedrock_converse", so the
|
||||
regional drift check above (which filters on "bedrock") never reaches them.
|
||||
GovCloud is a separate AWS partition that gets features later, so a us-gov profile
|
||||
may lack Bedrock native structured output its commercial base has, never the reverse.
|
||||
"""
|
||||
os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"
|
||||
litellm.model_cost = litellm.get_model_cost_map(url="")
|
||||
|
|
@ -318,6 +334,9 @@ def test_get_model_info_bedrock_cross_region_capability_parity():
|
|||
if not cap.startswith("supports_"):
|
||||
continue
|
||||
assert cap in v, f"{cap} is on {base_model_key} but missing from {k}"
|
||||
if _govcloud_may_lag(k, cap):
|
||||
assert base_value or not v[cap], f"{cap} is on {k} but not on {base_model_key}"
|
||||
continue
|
||||
assert (
|
||||
v[cap] == base_value
|
||||
), f"{cap} is {v[cap]} on {k} but {base_value} on {base_model_key}"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue