litellm/tests/unit/tracing/test_otlp_http.py
devin-ai-integration[bot] a7a3a6b375
test: migrate legacy unit dirs and unrun folders into tests/unit, tests/integration and tests/e2e (#45940)
* test: migrate legacy unit dirs and unrun folders into tests/unit, tests/integration and tests/e2e

* test: fix disk cache collection, ungate saturation check, drop RSS memory tests

* test: assert one delivered log per completion in Datadog and LangSmith checks

* test: drop SDK-direct e2e copies and align cost-map path filter cases

---------

Co-authored-by: yuneng <yuneng@berri.ai>
2026-10-11 06:24:57 -07:00

22 lines
859 B
Python

import pytest
from litellm.tracing.otlp_http import encode_otlp_response
def test_response_matches_request_encoding() -> None:
assert encode_otlp_response("application/json") == (b"{}", "application/json")
assert encode_otlp_response("application/json; charset=utf-8", "bad") == (
b'{"message": "bad"}',
"application/json",
)
assert encode_otlp_response("application/x-protobuf") == (b"", "application/x-protobuf")
assert encode_otlp_response(None) == (b"", "application/x-protobuf")
@pytest.mark.requires_rust_extension
def test_protobuf_error_is_an_rpc_status() -> None:
from google.rpc.status_pb2 import Status
body, media_type = encode_otlp_response("application/x-protobuf", "invalid trace")
assert media_type == "application/x-protobuf"
assert Status.FromString(body).message == "invalid trace"