mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-11 03:38:38 +00:00
test(router): add unit tests for _strip_http_framing_headers to satisfy router coverage gate
This commit is contained in:
parent
e891a7d765
commit
6c1511c876
1 changed files with 46 additions and 0 deletions
|
|
@ -5851,6 +5851,52 @@ class TestAdvisorSubCallCooldown:
|
|||
assert "dep-1" not in self._cooled_down_ids(router)
|
||||
|
||||
|
||||
def test_strip_http_framing_headers_removes_framing_and_preserves_rest():
|
||||
from litellm.router import _strip_http_framing_headers
|
||||
|
||||
class _FakeErr(Exception):
|
||||
pass
|
||||
|
||||
exc = _FakeErr("boom")
|
||||
exc.headers = {
|
||||
"content-length": "99",
|
||||
"transfer-encoding": "chunked",
|
||||
"content-encoding": "gzip",
|
||||
"content-type": "application/json",
|
||||
"set-cookie": "session=abc",
|
||||
"cookie": "token=xyz",
|
||||
"proxy-authenticate": "Basic realm=test",
|
||||
"proxy-authorization": "Basic dXNlcjpwYXNz",
|
||||
"x-request-id": "req-1",
|
||||
"retry-after": "30",
|
||||
}
|
||||
_strip_http_framing_headers(exc)
|
||||
headers = exc.headers
|
||||
for stripped in (
|
||||
"content-length", "transfer-encoding", "content-encoding", "content-type",
|
||||
"set-cookie", "cookie", "proxy-authenticate", "proxy-authorization",
|
||||
):
|
||||
assert stripped not in headers, f"{stripped} must be stripped"
|
||||
assert headers.get("x-request-id") == "req-1"
|
||||
assert headers.get("retry-after") == "30"
|
||||
|
||||
|
||||
def test_strip_http_framing_headers_no_headers_attr():
|
||||
from litellm.router import _strip_http_framing_headers
|
||||
|
||||
exc = ValueError("no headers attr")
|
||||
_strip_http_framing_headers(exc)
|
||||
|
||||
|
||||
def test_strip_http_framing_headers_non_dict_headers():
|
||||
from litellm.router import _strip_http_framing_headers
|
||||
|
||||
exc = ValueError("non-mappable headers")
|
||||
exc.headers = "not-a-mapping"
|
||||
_strip_http_framing_headers(exc)
|
||||
assert exc.headers == "not-a-mapping"
|
||||
|
||||
|
||||
def test_get_configured_token_limits_reads_deployment_model_info():
|
||||
router = litellm.Router(
|
||||
model_list=[
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue