mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
test: cover nested policy response models
This commit is contained in:
parent
541f86ca53
commit
d9789919ff
1 changed files with 18 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ import json
|
|||
|
||||
import pytest
|
||||
from fastapi.encoders import jsonable_encoder
|
||||
from pydantic import BaseModel
|
||||
|
||||
from litellm.proxy.policy_engine.policy_endpoints import (
|
||||
_dump_pipeline_result_for_response,
|
||||
|
|
@ -19,6 +20,10 @@ class OpaqueSpan:
|
|||
return "opaque-span"
|
||||
|
||||
|
||||
class NestedPolicyPayload(BaseModel):
|
||||
value: str
|
||||
|
||||
|
||||
def test_pipeline_test_response_removes_internal_non_json_values():
|
||||
opaque_span = OpaqueSpan()
|
||||
result = PipelineExecutionResult(
|
||||
|
|
@ -58,3 +63,16 @@ def test_pipeline_test_response_removes_internal_non_json_values():
|
|||
dumped["step_results"][0]["modified_data"]["non_internal_object"]
|
||||
== "opaque-span"
|
||||
)
|
||||
|
||||
|
||||
def test_pipeline_test_response_preserves_nested_pydantic_models():
|
||||
result = PipelineExecutionResult(
|
||||
terminal_action="allow",
|
||||
step_results=[],
|
||||
modified_data={"nested": NestedPolicyPayload(value="kept")},
|
||||
)
|
||||
|
||||
dumped = _dump_pipeline_result_for_response(result)
|
||||
|
||||
json.dumps(dumped)
|
||||
assert dumped["modified_data"]["nested"] == {"value": "kept"}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue