Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Fix: test_pass_through_endpoint_bing

Sameer Kankuteadb91d442ab8
diff --git a/tests/local_testing/test_pass_through_endpoints.py b/tests/local_testing/test_pass_through_endpoints.py
index 2795bc918b9..3ca504fc6e7 100644
--- a/tests/local_testing/test_pass_through_endpoints.py
+++ b/tests/local_testing/test_pass_through_endpoints.py
@@ -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
)