From adb91d442ab8cc4eb87cef2c5c9a3f64d52ddbd9 Mon Sep 17 00:00:00 2001 From: Sameer Kankute Date: Fri, 20 Feb 2026 09:01:29 +0530 Subject: [PATCH] Fix: test_pass_through_endpoint_bing --- .../test_pass_through_endpoints.py | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/tests/local_testing/test_pass_through_endpoints.py b/tests/local_testing/test_pass_through_endpoints.py index 2795bc918b..3ca504fc6e 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 )