Skip to content

Commit 365b6c7

Browse files
committed
Include full url with query params from mock helper
1 parent 1d5aadb commit 365b6c7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
cast,
1212
)
1313
from unittest.mock import AsyncMock, MagicMock
14+
import urllib.parse
1415

1516
import httpx
1617
import pytest
@@ -162,6 +163,14 @@ def inner(
162163
def capture_and_mock(*args, **kwargs):
163164
request_kwargs.update(kwargs)
164165

166+
# Capture full URL with encoded params while keeping original URL
167+
if kwargs and "params" in kwargs and kwargs["params"]:
168+
# Convert params to query string with proper URL encoding
169+
query_string = urllib.parse.urlencode(
170+
kwargs["params"], doseq=True, quote_via=urllib.parse.quote_plus
171+
)
172+
request_kwargs.update({"full_url": f"{kwargs['url']}?{query_string}"})
173+
165174
return httpx.Response(
166175
status_code=status_code,
167176
headers=headers,

0 commit comments

Comments
 (0)