test_queryparams.py
This file
Path
tests/client/test_queryparams.py
54 lines · 1.6 KiB · Python
Last changed by
Httpcore interface (#804)Tom Christiebefore adoption3046e92
History of this fileTake it
The walk stopped after 200 commits: lines older than 07586f9 point at it.
Httpcore interface (#804)Tom Christiebefore adoption3046e92
line 1why, one step back1import typingConvert debug logs to trace logs (#500)Florimond Mancabefore adoption07586f9
line 2why, one step back2Httpcore interface (#804)Tom Christiebefore adoption3046e92
line 3why, one step back3import httpcoreDrop sync (#544)Tom Christiebefore adoption206c537
lines 4–5why, one step back4import pytest5Httpcore interface (#804)Tom Christiebefore adoption3046e92
lines 6–7why, one step back6from httpx import URL, AsyncClient, Headers, QueryParams7from httpx._content_streams import ContentStream, JSONStreamConvert debug logs to trace logs (#500)Florimond Mancabefore adoption07586f9
lines 8–9why, one step back89Httpcore interface (#804)Tom Christiebefore adoption3046e92
lines 10–11why, one step back10class MockDispatch(httpcore.AsyncHTTPTransport):11 async def request(Convert debug logs to trace logs (#500)Florimond Mancabefore adoption07586f9
line 12why, one step back12 self,Httpcore interface (#804)Tom Christiebefore adoption3046e92
lines 13–23why, one step back13 method: bytes,14 url: typing.Tuple[bytes, bytes, int, bytes],15 headers: typing.List[typing.Tuple[bytes, bytes]],16 stream: ContentStream,17 timeout: typing.Dict[str, typing.Optional[float]] = None,18 ) -> typing.Tuple[19 bytes, int, bytes, typing.List[typing.Tuple[bytes, bytes]], ContentStream20 ]:21 headers = Headers()22 body = JSONStream({"ok": "ok"})23 return b"HTTP/1.1", 200, b"OK", headers, bodyConvert debug logs to trace logs (#500)Florimond Mancabefore adoption07586f9
lines 24–26why, one step back242526def test_client_queryparams():Rename Client to AsyncClient (with compat synonym) (#680)Florimond Mancabefore adoptione284b84
line 27why, one step back27 client = AsyncClient(params={"a": "b"})Convert debug logs to trace logs (#500)Florimond Mancabefore adoption07586f9
lines 28–32why, one step back28 assert isinstance(client.params, QueryParams)29 assert client.params["a"] == "b"303132def test_client_queryparams_string():Rename Client to AsyncClient (with compat synonym) (#680)Florimond Mancabefore adoptione284b84
line 33why, one step back33 client = AsyncClient(params="a=b")Convert debug logs to trace logs (#500)Florimond Mancabefore adoption07586f9
lines 34–36why, one step back34 assert isinstance(client.params, QueryParams)35 assert client.params["a"] == "b"36Rename Client to AsyncClient (with compat synonym) (#680)Florimond Mancabefore adoptione284b84
line 37why, one step back37 client = AsyncClient()Convert debug logs to trace logs (#500)Florimond Mancabefore adoption07586f9
lines 38–42why, one step back38 client.params = "a=b"39 assert isinstance(client.params, QueryParams)40 assert client.params["a"] == "b"4142Drop sync (#544)Tom Christiebefore adoption206c537
lines 43–44why, one step back43@pytest.mark.asyncio44async def test_client_queryparams_echo():Convert debug logs to trace logs (#500)Florimond Mancabefore adoption07586f9
lines 45–47why, one step back45 url = "http://example.org/echo_queryparams"46 client_queryparams = "first=str"47 request_queryparams = {"second": "dict"}Rename Client to AsyncClient (with compat synonym) (#680)Florimond Mancabefore adoptione284b84
line 48why, one step back48 client = AsyncClient(dispatch=MockDispatch(), params=client_queryparams)Drop sync (#544)Tom Christiebefore adoption206c537
line 49why, one step back49 response = await client.get(url, params=request_queryparams)Convert debug logs to trace logs (#500)Florimond Mancabefore adoption07586f9
lines 50–54why, one step back5051 assert response.status_code == 20052 assert response.url == URL(53 "http://example.org/echo_queryparams?first=str&second=dict"54 )