test: give the new proxy_server-global patches a test-quality reason

This commit is contained in:
Yuneng Jiang 2026-09-19 12:49:17 -07:00
parent 9905458e25
commit 5de9fc6961
No known key found for this signature in database
3 changed files with 12 additions and 12 deletions

View file

@ -291,7 +291,7 @@ async def test_save_email_settings_refuses_a_config_owned_email_settings():
client = _prisma_recording_upserts(upserts)
proxy_config = _proxy_config_owning({"email_settings": {EmailEvent.new_user_invitation.value: True}})
with mock.patch("litellm.proxy.proxy_server.proxy_config", proxy_config):
with mock.patch("litellm.proxy.proxy_server.proxy_config", proxy_config): # test-quality-ok: the endpoint reads these proxy_server module globals at call time; there is no injection seam
with pytest.raises(HTTPException) as refused:
await _save_email_settings(client, {EmailEvent.new_user_invitation.value: False})
@ -309,8 +309,8 @@ async def test_update_event_settings_surfaces_the_config_owned_refusal(mock_user
settings=[EmailEventSettings(event=EmailEvent.virtual_key_created, enabled=True)]
)
with mock.patch("litellm.proxy.proxy_server.prisma_client", client):
with mock.patch("litellm.proxy.proxy_server.proxy_config", proxy_config):
with mock.patch("litellm.proxy.proxy_server.prisma_client", client): # test-quality-ok: the endpoint reads these proxy_server module globals at call time; there is no injection seam
with mock.patch("litellm.proxy.proxy_server.proxy_config", proxy_config): # test-quality-ok: the endpoint reads these proxy_server module globals at call time; there is no injection seam
with pytest.raises(HTTPException) as refused:
await update_event_settings(request=request, user_api_key_dict=mock_user_api_key_auth)
@ -325,7 +325,7 @@ async def test_save_email_settings_still_writes_when_the_config_file_is_silent()
client = _prisma_recording_upserts(upserts)
proxy_config = _proxy_config_owning({})
with mock.patch("litellm.proxy.proxy_server.proxy_config", proxy_config):
with mock.patch("litellm.proxy.proxy_server.proxy_config", proxy_config): # test-quality-ok: the endpoint reads these proxy_server module globals at call time; there is no injection seam
await _save_email_settings(client, {EmailEvent.new_user_invitation.value: False})
assert len(upserts) == 1

View file

@ -431,7 +431,7 @@ def test_settings_store_truthiness_stops_at_the_first_key() -> None:
resolutions.append(key)
return original(self, key)
with patch.object(SettingsStore, "_resolution_for", counted):
with patch.object(SettingsStore, "_resolution_for", counted): # test-quality-ok: counting resolutions is the only way to observe that truthiness short-circuits
assert bool(store) is True
truthiness_resolutions: Final = len(resolutions)
resolutions.clear()

View file

@ -636,9 +636,9 @@ async def test_update_refuses_a_config_owned_coordination_redis_block(monkeypatc
from_file = {"coordination_redis": {"host": "yaml-redis.example.com", "port": 6379}}
with (
patch("litellm.proxy.proxy_server.prisma_client", mock_prisma),
patch("litellm.proxy.proxy_server.proxy_config", _real_proxy_config(from_file)),
patch("litellm.proxy.proxy_server.store_model_in_db", True),
patch("litellm.proxy.proxy_server.prisma_client", mock_prisma), # test-quality-ok: the endpoint reads these proxy_server module globals at call time; there is no injection seam
patch("litellm.proxy.proxy_server.proxy_config", _real_proxy_config(from_file)), # test-quality-ok: the endpoint reads these proxy_server module globals at call time; there is no injection seam
patch("litellm.proxy.proxy_server.store_model_in_db", True), # test-quality-ok: the endpoint reads these proxy_server module globals at call time; there is no injection seam
):
with pytest.raises(HTTPException) as refused:
await update_coordination_redis_settings(
@ -661,10 +661,10 @@ async def test_update_still_persists_when_the_config_file_declares_no_block(monk
return None
with (
patch("litellm.proxy.proxy_server.prisma_client", mock_prisma),
patch("litellm.proxy.proxy_server.proxy_config", _real_proxy_config({"master_key": "sk-1234"})),
patch("litellm.proxy.proxy_server.store_model_in_db", True),
patch(
patch("litellm.proxy.proxy_server.prisma_client", mock_prisma), # test-quality-ok: the endpoint reads these proxy_server module globals at call time; there is no injection seam
patch("litellm.proxy.proxy_server.proxy_config", _real_proxy_config({"master_key": "sk-1234"})), # test-quality-ok: the endpoint reads these proxy_server module globals at call time; there is no injection seam
patch("litellm.proxy.proxy_server.store_model_in_db", True), # test-quality-ok: the endpoint reads these proxy_server module globals at call time; there is no injection seam
patch( # test-quality-ok: the endpoint reads these proxy_server module globals at call time; there is no injection seam
"litellm.proxy.management_endpoints.coordination_redis_endpoints.invalidate_config_param",
new=_capture_invalidate,
),