You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found that if I set encoded=True then it is passing, though this seems a little sketchy :D as httpx seems to auto encode but other http clients might not
importhttpximportrespxfromfastapiimportFastAPI, QueryfromuplinkimportConsumerfromuplinkimportQueryasQfromuplinkimportget, returnsfromuplink_httpximportHttpxClient### Given: Mock ServerBASE_URL="https://mock.api/"app=FastAPI()
@app.get("/user")defget_user(select: str=Query(alias="$select")):
return {"id": select}
mock_api=respx.mock(base_url=BASE_URL, assert_all_called=False)
mock_api.route().mock(side_effect=respx.ASGIHandler(app))
### When: ClientclassBasicClient(Consumer):
@get("user")@returns.json()defuser(self, select: Q("$select", encoded=True)):
...
### Then: Should work with either raw client or uplink client@mock_apiasyncdeftest_raw():
client=BasicClient(base_url=BASE_URL, client=HttpxClient())
resp=awaitclient.user(select=123)
assertresp.status_code==200assertresp.json() == {"id": "123"}
@mock_apiasyncdeftest_uplink():
resp=awaithttpx.AsyncClient().get(f"{BASE_URL}user?$select=123")
assertresp.status_code==200assertresp.json() == {"id": "123"}
Describe the bug
Query params are being encoded too early so cannot be effectively mocked
To Reproduce
See full dialog in chassing/uplink-httpx#6
Expected behavior
See full dialog in chassing/uplink-httpx#6
Additional context
This seems to be an edge case when the characters are need percent url encoding
The text was updated successfully, but these errors were encountered: