Fix: test_pass_through_endpoint_bing

This commit is contained in:
Sameer Kankute
2026-02-20 17:28:17 -08:00
committed by yuneng-jiang
parent 61eaf96046
commit adb91d442a
@@ -3,6 +3,7 @@ import sys
from litellm._uuid import uuid
from functools import partial
from typing import Optional
from urllib.parse import urlparse, parse_qs
import pytest
from fastapi import FastAPI
@@ -535,10 +536,27 @@ async def test_pass_through_endpoint_bing(client, monkeypatch):
first_transformed_url = captured_requests[0][1]["url"]
second_transformed_url = captured_requests[1][1]["url"]
# Assert the response
# Parse URLs to compare query params order-independently
# Parse first URL
parsed_first = urlparse(str(first_transformed_url))
first_params = parse_qs(parsed_first.query)
# Parse second URL
parsed_second = urlparse(str(second_transformed_url))
second_params = parse_qs(parsed_second.query)
# Expected values (parse_qs decodes + as space)
expected_first_params = {"q": ["bob barker"], "setLang": ["en-US"], "mkt": ["en-US"]}
expected_second_params = {"setLang": ["en-US"], "mkt": ["en-US"]}
# Assert the response - compare base URL and params separately
assert (
first_transformed_url
== "https://api.bing.microsoft.com/v7.0/search?q=bob+barker&setLang=en-US&mkt=en-US"
and second_transformed_url
== "https://api.bing.microsoft.com/v7.0/search?setLang=en-US&mkt=en-US"
parsed_first.scheme == "https"
and parsed_first.netloc == "api.bing.microsoft.com"
and parsed_first.path == "/v7.0/search"
and first_params == expected_first_params
and parsed_second.scheme == "https"
and parsed_second.netloc == "api.bing.microsoft.com"
and parsed_second.path == "/v7.0/search"
and second_params == expected_second_params
)