litellm/tests/unit/integrations/test_email_alerting.py
Mateo Wang 3f38730d2c
refactor(typing): clear about 1,100 basedpyright Any errors across 303 files (#49986)
* 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
2026-11-06 13:31:15 -08:00

33 lines
1.2 KiB
Python

from types import SimpleNamespace
from typing import Final
from unittest.mock import AsyncMock
import pytest
from litellm.integrations.email_alerting import get_all_team_member_emails
from litellm.proxy import proxy_server
@pytest.mark.asyncio
async def test_team_member_emails_are_the_set_emails_of_the_members_with_a_user_id(
monkeypatch: pytest.MonkeyPatch,
) -> None:
team: Final = SimpleNamespace(
members_with_roles=[{"user_id": "u-1", "role": "admin"}, {"role": "user"}, {"user_id": "u-2", "role": "user"}]
)
query_raw: Final = AsyncMock(
return_value=[{"user_email": "a@example.com"}, {"user_email": None}, {}, {"user_email": "b@example.com"}]
)
prisma_client: Final = SimpleNamespace(
db=SimpleNamespace(
litellm_teamtable=SimpleNamespace(find_unique=AsyncMock(return_value=team)),
query_raw=query_raw,
)
)
monkeypatch.setattr(proxy_server, "prisma_client", prisma_client)
emails: Final = await get_all_team_member_emails("team-1")
assert emails == ["a@example.com", "b@example.com"]
assert query_raw.await_args is not None
assert query_raw.await_args.args[1] == ["u-1", "u-2"]