Skip to content
Myr

test_queryparams.py

This file

Path

tests/client/test_queryparams.py

53 lines · 1.7 KiB · Python

Last changed by

Type check tests (#1054)Florimond Mancabefore adoption0296c2b

History of this file

Take it

The walk stopped after 200 commits: lines older than fe86c0c point at it.

Httpcore interface (#804)Tom Christiebefore adoption3046e92

line 1why, one step back
1import typing

Drop unused SSLConfig.with_overrides (#702)Tom Christiebefore adoptionfe86c0c

line 2why, one step back
2

Httpcore interface (#804)Tom Christiebefore adoption3046e92

line 3why, one step back
3import httpcore

Drop unused SSLConfig.with_overrides (#702)Tom Christiebefore adoptionfe86c0c

lines 4–5why, one step back
4import pytest
5

Type check tests (#1054)Florimond Mancabefore adoption0296c2b

line 6why, one step back
6from httpx import URL, AsyncClient, QueryParams

Httpcore interface (#804)Tom Christiebefore adoption3046e92

line 7why, one step back
7from httpx._content_streams import ContentStream, JSONStream

Drop unused SSLConfig.with_overrides (#702)Tom Christiebefore adoptionfe86c0c

lines 8–9why, one step back
8
9

Replace remaining occurrences of dispatch with transport (#1010)Josep Cugatbefore adoption89a8100

line 10why, one step back
10class MockTransport(httpcore.AsyncHTTPTransport):

Httpcore interface (#804)Tom Christiebefore adoption3046e92

line 11why, one step back
11 async def request(

Drop unused SSLConfig.with_overrides (#702)Tom Christiebefore adoptionfe86c0c

line 12why, one step back
12 self,

Httpcore interface (#804)Tom Christiebefore adoption3046e92

line 13why, one step back
13 method: bytes,

Type check tests (#1054)Florimond Mancabefore adoption0296c2b

lines 14–16why, one step back
14 url: typing.Tuple[bytes, bytes, typing.Optional[int], bytes],
15 headers: typing.List[typing.Tuple[bytes, bytes]] = None,16 stream: httpcore.AsyncByteStream = None,

Httpcore interface (#804)Tom Christiebefore adoption3046e92

lines 17–21why, one step back
17 timeout: typing.Dict[str, typing.Optional[float]] = None,
18 ) -> typing.Tuple[19 bytes, int, bytes, typing.List[typing.Tuple[bytes, bytes]], ContentStream20 ]:21 body = JSONStream({"ok": "ok"})

Type check tests (#1054)Florimond Mancabefore adoption0296c2b

line 22why, one step back
22 return b"HTTP/1.1", 200, b"OK", [], body

Drop unused SSLConfig.with_overrides (#702)Tom Christiebefore adoptionfe86c0c

lines 23–36why, one step back
23
2425def test_client_queryparams():26 client = AsyncClient(params={"a": "b"})27 assert isinstance(client.params, QueryParams)28 assert client.params["a"] == "b"293031def test_client_queryparams_string():32 client = AsyncClient(params="a=b")33 assert isinstance(client.params, QueryParams)34 assert client.params["a"] == "b"3536 client = AsyncClient()

Type check tests (#1054)Florimond Mancabefore adoption0296c2b

line 37why, one step back
37 client.params = "a=b" # type: ignore

Drop unused SSLConfig.with_overrides (#702)Tom Christiebefore adoptionfe86c0c

lines 38–46why, one step back
38 assert isinstance(client.params, QueryParams)
39 assert client.params["a"] == "b"404142@pytest.mark.asyncio43async def test_client_queryparams_echo():44 url = "http://example.org/echo_queryparams"45 client_queryparams = "first=str"46 request_queryparams = {"second": "dict"}

Replace remaining occurrences of dispatch with transport (#1010)Josep Cugatbefore adoption89a8100

line 47why, one step back
47 client = AsyncClient(transport=MockTransport(), params=client_queryparams)

Drop unused SSLConfig.with_overrides (#702)Tom Christiebefore adoptionfe86c0c

lines 48–53why, one step back
48 response = await client.get(url, params=request_queryparams)
4950 assert response.status_code == 20051 assert response.url == URL(52 "http://example.org/echo_queryparams?first=str&second=dict"53 )