test_queryparams.py
This file
Path
tests/client/test_queryparams.py
54 lines · 1.6 KiB · Python
Last changed by
Replace remaining occurrences of dispatch with transport (#1010)Josep Cugatbefore adoption89a8100
History of this fileTake it
The walk stopped after 200 commits: lines older than c38fd68 point at it.
Httpcore interface (#804)Tom Christiebefore adoption3046e92
line 1why, one step back1import typingDrop BackgroundManager in favor of fork(func1, func2) (#603)Florimond Mancabefore adoptionc38fd68
line 2why, one step back2Httpcore interface (#804)Tom Christiebefore adoption3046e92
line 3why, one step back3import httpcoreDrop BackgroundManager in favor of fork(func1, func2) (#603)Florimond Mancabefore adoptionc38fd68
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, JSONStreamDrop BackgroundManager in favor of fork(func1, func2) (#603)Florimond Mancabefore adoptionc38fd68
lines 8–9why, one step back89Replace remaining occurrences of dispatch with transport (#1010)Josep Cugatbefore adoption89a8100
line 10why, one step back10class MockTransport(httpcore.AsyncHTTPTransport):Httpcore interface (#804)Tom Christiebefore adoption3046e92
line 11why, one step back11 async def request(Drop BackgroundManager in favor of fork(func1, func2) (#603)Florimond Mancabefore adoptionc38fd68
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, bodyDrop BackgroundManager in favor of fork(func1, func2) (#603)Florimond Mancabefore adoptionc38fd68
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"})Drop BackgroundManager in favor of fork(func1, func2) (#603)Florimond Mancabefore adoptionc38fd68
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")Drop BackgroundManager in favor of fork(func1, func2) (#603)Florimond Mancabefore adoptionc38fd68
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()Drop BackgroundManager in favor of fork(func1, func2) (#603)Florimond Mancabefore adoptionc38fd68
lines 38–47why, one step back38 client.params = "a=b"39 assert isinstance(client.params, QueryParams)40 assert client.params["a"] == "b"414243@pytest.mark.asyncio44async def test_client_queryparams_echo():45 url = "http://example.org/echo_queryparams"46 client_queryparams = "first=str"47 request_queryparams = {"second": "dict"}Replace remaining occurrences of dispatch with transport (#1010)Josep Cugatbefore adoption89a8100
line 48why, one step back48 client = AsyncClient(transport=MockTransport(), params=client_queryparams)Drop BackgroundManager in favor of fork(func1, func2) (#603)Florimond Mancabefore adoptionc38fd68
lines 49–54why, one step back49 response = await client.get(url, params=request_queryparams)5051 assert response.status_code == 20052 assert response.url == URL(53 "http://example.org/echo_queryparams?first=str&second=dict"54 )