Skip to content

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]

fix: litellm/tests/test_litellm/test_responses_id_security.py

Sameer Kankute62d860ea7d93
diff --git a/tests/test_litellm/test_responses_id_security.py b/tests/test_litellm/test_responses_id_security.py
index 6b04479326e..2addf504f7c 100644
--- a/tests/test_litellm/test_responses_id_security.py
+++ b/tests/test_litellm/test_responses_id_security.py
@@ -42,8 +42,11 @@ class TestIsEncryptedResponseId:
def test_is_encrypted_response_id_valid(self, responses_id_security):
"""Test that a properly encrypted response ID is identified correctly"""
- with patch(
- "litellm.proxy.hooks.responses_id_security.decrypt_value_helper"
+ # Patch at the module level where it's imported
+ import litellm.proxy.hooks.responses_id_security as responses_module
+
+ with patch.object(
+ responses_module, "decrypt_value_helper"
) as mock_decrypt:
mock_decrypt.return_value = f"{SpecialEnums.LITELM_MANAGED_FILE_ID_PREFIX.value}response_id:resp_123;user_id:user-456"
@@ -56,8 +59,11 @@ class TestIsEncryptedResponseId:
def test_is_encrypted_response_id_invalid(self, responses_id_security):
"""Test that an unencrypted response ID returns False"""
- with patch(
- "litellm.proxy.hooks.responses_id_security.decrypt_value_helper"
+ # Patch at the module level where it's imported
+ import litellm.proxy.hooks.responses_id_security as responses_module
+
+ with patch.object(
+ responses_module, "decrypt_value_helper"
) as mock_decrypt:
mock_decrypt.return_value = None
@@ -71,8 +77,11 @@ class TestDecryptResponseId:
def test_decrypt_response_id_valid(self, responses_id_security):
"""Test decrypting a valid encrypted response ID"""
- with patch(
- "litellm.proxy.hooks.responses_id_security.decrypt_value_helper"
+ # Patch at the module level where it's imported
+ import litellm.proxy.hooks.responses_id_security as responses_module
+
+ with patch.object(
+ responses_module, "decrypt_value_helper"
) as mock_decrypt:
mock_decrypt.return_value = f"{SpecialEnums.LITELM_MANAGED_FILE_ID_PREFIX.value}response_id:resp_original_123;user_id:user-456;team_id:team-789"
@@ -86,8 +95,11 @@ class TestDecryptResponseId:
def test_decrypt_response_id_no_encryption(self, responses_id_security):
"""Test decrypting a non-encrypted response ID"""
- with patch(
- "litellm.proxy.hooks.responses_id_security.decrypt_value_helper"
+ # Patch at the module level where it's imported
+ import litellm.proxy.hooks.responses_id_security as responses_module
+
+ with patch.object(
+ responses_module, "decrypt_value_helper"
) as mock_decrypt:
mock_decrypt.return_value = None