88import pytest
99from fastapi .testclient import TestClient
1010from httpx import Request
11- from utils import AppFactory
11+ from utils import AppFactory , parse_query_string
1212
1313FILTER_EXPR_CASES = [
1414 pytest .param (
@@ -151,7 +151,7 @@ async def _get_upstream_request(mock_upstream: MagicMock):
151151 assert mock_upstream .call_count == 1
152152 [request ] = cast (list [Request ], mock_upstream .call_args [0 ])
153153 req_body = request ._streamed_body
154- return req_body .decode (), dict (request .url .params )
154+ return req_body .decode (), parse_query_string (request .url .query . decode ( "utf-8" ) )
155155
156156
157157@pytest .mark .parametrize (
@@ -219,12 +219,13 @@ async def test_search_get(
219219 token_builder ,
220220):
221221 """Test that GET /search merges the upstream query params with the templated filter."""
222- response = _build_client (
222+ client = _build_client (
223223 src_api_server = source_api_server ,
224224 template_expr = filter_template_expr ,
225225 is_authenticated = is_authenticated ,
226226 token_builder = token_builder ,
227- ).get ("/search" , params = input_query )
227+ )
228+ response = client .get ("/search" , params = input_query )
228229 response .raise_for_status ()
229230
230231 # For GET, we expect the upstream body to be empty, but URL params to be appended
@@ -239,13 +240,15 @@ async def test_search_get(
239240 if input_filter :
240241 proxy_filter += cql2 .Expr (input_filter )
241242
243+ filter_lang = input_query .get ("filter-lang" , "cql2-text" )
242244 expected_output = {
243245 ** input_query ,
244246 "filter" : (
245247 proxy_filter .to_text ()
246- if input_query . get ( "filter-lang" ) == "cql2-text"
248+ if filter_lang == "cql2-text"
247249 else proxy_filter .to_json ()
248250 ),
251+ "filter-lang" : filter_lang ,
249252 }
250253 assert (
251254 upstream_query == expected_output
0 commit comments