The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test(managed-files): call store_unified_file_id twice and assert upsert payloads
mateo-berri04d702c46ae0
diff --git a/tests/test_litellm/enterprise/proxy/test_managed_files_hook.py b/tests/test_litellm/enterprise/proxy/test_managed_files_hook.pyindex 1526aad7a24..2580197d6d2 100644--- a/tests/test_litellm/enterprise/proxy/test_managed_files_hook.py+++ b/tests/test_litellm/enterprise/proxy/test_managed_files_hook.py@@ -5,6 +5,8 @@ Regression test for afile_retrieve called without credentials inasync_post_call_success_hook when processing completed batch responses."""+import json+import pytestfrom typing import Optionalfrom unittest.mock import AsyncMock, MagicMock, patch@@ -421,18 +423,23 @@ async def test_store_unified_file_id_is_idempotent_via_upsert():unified_file_id, never do an unconditional create that raises on conflict."""managed_files, mock_prisma = _make_real_managed_files_instance()file_id = "litellm_proxy_unified_output_id_abc"+ model_mappings = {"model-deploy-xyz": "file-output-abc"}- await managed_files.store_unified_file_id(- file_id=file_id,- file_object=_make_file_object(),- litellm_parent_otel_span=None,- model_mappings={"model-deploy-xyz": "file-output-abc"},- user_api_key_dict=_make_user_api_key_dict(),- )+ for _ in range(2):+ await managed_files.store_unified_file_id(+ file_id=file_id,+ file_object=_make_file_object(),+ litellm_parent_otel_span=None,+ model_mappings=model_mappings,+ user_api_key_dict=_make_user_api_key_dict(),+ )mock_prisma.db.litellm_managedfiletable.create.assert_not_awaited()- mock_prisma.db.litellm_managedfiletable.upsert.assert_awaited_once()- assert (- mock_prisma.db.litellm_managedfiletable.upsert.await_args.kwargs["where"]- == {"unified_file_id": file_id}- )+ upsert_mock = mock_prisma.db.litellm_managedfiletable.upsert+ assert upsert_mock.await_count == 2+ for upsert_call in upsert_mock.await_args_list:+ assert upsert_call.kwargs["where"] == {"unified_file_id": file_id}+ upsert_data = upsert_call.kwargs["data"]+ assert upsert_data["create"]["unified_file_id"] == file_id+ assert json.loads(upsert_data["create"]["model_mappings"]) == model_mappings+ assert json.loads(upsert_data["update"]["model_mappings"]) == model_mappings