From 1a990af6528b8ec54e5f55cc6cc72d8318790663 Mon Sep 17 00:00:00 2001 From: mateo Date: Tue, 6 Oct 2026 00:08:46 +0000 Subject: [PATCH] test: cover hidden params accessors across response types Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- tests/unit/types/test_types_utils.py | 57 +++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/tests/unit/types/test_types_utils.py b/tests/unit/types/test_types_utils.py index c032e3f3ddf..84349300a17 100644 --- a/tests/unit/types/test_types_utils.py +++ b/tests/unit/types/test_types_utils.py @@ -1,9 +1,25 @@ import json -from typing import Final +from typing import Final, Protocol, cast import pytest - +from litellm.litellm_core_utils.hidden_params import HIDDEN_PARAMS_ATTR +from litellm.types.agents import ( + AgentCreateResponse, + AgentDeleteResult, + AgentListResponse, + AgentVersionsResponse, + LiteLLMSendMessageResponse, +) +from litellm.types.containers.main import ContainerFileObject, ContainerObject +from litellm.types.google_genai.main import GenerateContentResponse +from litellm.types.interactions.generated import ( + CancelInteractionResult, + DeleteInteractionResult, + InteractionsAPIResponse, + InteractionsAPIStreamingResponse, +) +from litellm.types.responses.main import DeleteResponseResult from litellm.types.utils import ( EmbeddingResponse, HiddenParams, @@ -16,6 +32,14 @@ from litellm.types.utils import ( ) +class _DictHiddenParamsAccessor(Protocol): + @property + def hidden_params(self) -> dict[str, object]: ... + + @hidden_params.setter + def hidden_params(self, hidden_params: dict[str, object]) -> None: ... + + def test_rust_is_a_known_litellm_param(): assert "rust" in all_litellm_params @@ -47,6 +71,35 @@ def test_hidden_params_public_accessor_preserves_identity_and_instance_isolation assert response.hidden_params is replacement +@pytest.mark.parametrize( + "response", + ( + AgentCreateResponse.model_construct(), + AgentDeleteResult.model_construct(), + AgentListResponse.model_construct(), + AgentVersionsResponse.model_construct(), + LiteLLMSendMessageResponse.model_construct(), + ContainerObject.model_construct(), + ContainerFileObject.model_construct(), + GenerateContentResponse(), + InteractionsAPIResponse.model_construct(), + InteractionsAPIStreamingResponse.model_construct(), + DeleteInteractionResult.model_construct(), + CancelInteractionResult.model_construct(), + DeleteResponseResult.model_construct(), + ), +) +def test_hidden_params_public_accessor_updates_its_backing_storage( + response: _DictHiddenParamsAccessor, +) -> None: + current: Final = response.hidden_params + assert cast(object, getattr(response, HIDDEN_PARAMS_ATTR)) is current + + replacement: Final = {"replacement": "visible"} + response.hidden_params = replacement + assert cast(object, getattr(response, HIDDEN_PARAMS_ATTR)) is replacement + + def test_chat_completion_delta_tool_call(): from litellm.types.utils import ChatCompletionDeltaToolCall, Function