Skip to content
Myr

test_queryparams.py

This file

Path

tests/models/test_queryparams.py

94 lines · 2.5 KiB · Python

Last changed by

Tweak QueryParams implementation (#1598)Tom Christiebefore adoption8fe32c5

History of this file

Take it

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

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 1–2why, one step back
1import pytest
2

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 3why, one step back
3import httpx

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 4–11why, one step back
4
56@pytest.mark.parametrize(7 "source",8 [9 "a=123&a=456&b=789",10 {"a": ["123", "456"], "b": 789},11 {"a": ("123", "456"), "b": 789},

Allow tuple as input of query parameters. (#1426)SarunasAznabefore adoption8696405

lines 12–13why, one step back
12 [("a", "123"), ("a", "456"), ("b", "789")],
13 (("a", "123"), ("a", "456"), ("b", "789")),

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 14–16why, one step back
14 ],
15)16def test_queryparams(source):

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 17why, one step back
17 q = httpx.QueryParams(source)

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 18–20why, one step back
18 assert "a" in q
19 assert "A" not in q20 assert "c" not in q

Tweak QueryParams implementation (#1598)Tom Christiebefore adoption8fe32c5

lines 21–22why, one step back
21 assert q["a"] == "123"
22 assert q.get("a") == "123"

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 23–26why, one step back
23 assert q.get("nope", default=None) is None
24 assert q.get_list("a") == ["123", "456"]2526 assert list(q.keys()) == ["a", "b"]

Tweak QueryParams implementation (#1598)Tom Christiebefore adoption8fe32c5

lines 27–28why, one step back
27 assert list(q.values()) == ["123", "789"]
28 assert list(q.items()) == [("a", "123"), ("b", "789")]

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 29–30why, one step back
29 assert len(q) == 2
30 assert list(q) == ["a", "b"]

Tweak QueryParams implementation (#1598)Tom Christiebefore adoption8fe32c5

line 31why, one step back
31 assert dict(q) == {"a": "123", "b": "789"}

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 32–33why, one step back
32 assert str(q) == "a=123&a=456&b=789"
33 assert repr(q) == "QueryParams('a=123&a=456&b=789')"

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 34why, one step back
34 assert httpx.QueryParams({"a": "123", "b": "456"}) == httpx.QueryParams(

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 35–36why, one step back
35 [("a", "123"), ("b", "456")]
36 )

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

lines 37–40why, one step back
37 assert httpx.QueryParams({"a": "123", "b": "456"}) == httpx.QueryParams(
38 "a=123&b=456"39 )40 assert httpx.QueryParams({"a": "123", "b": "456"}) == httpx.QueryParams(

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 41–42why, one step back
41 {"b": "456", "a": "123"}
42 )

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

lines 43–47why, one step back
43 assert httpx.QueryParams() == httpx.QueryParams({})
44 assert httpx.QueryParams([("a", "123"), ("a", "456")]) == httpx.QueryParams(45 "a=123&a=456"46 )47 assert httpx.QueryParams({"a": "123", "b": "456"}) != "invalid"

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

line 48why, one step back
48

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

lines 49–50why, one step back
49 q = httpx.QueryParams([("a", "123"), ("a", "456")])
50 assert httpx.QueryParams(q) == q

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 51–53why, one step back
51
5253def test_queryparam_types():

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 54why, one step back
54 q = httpx.QueryParams(None)

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 55–56why, one step back
55 assert str(q) == ""
56

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 57why, one step back
57 q = httpx.QueryParams({"a": True})

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 58–59why, one step back
58 assert str(q) == "a=true"
59

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 60why, one step back
60 q = httpx.QueryParams({"a": False})

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 61–62why, one step back
61 assert str(q) == "a=false"
62

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 63why, one step back
63 q = httpx.QueryParams({"a": ""})

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 64–65why, one step back
64 assert str(q) == "a="
65

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 66why, one step back
66 q = httpx.QueryParams({"a": None})

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 67–68why, one step back
67 assert str(q) == "a="
68

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 69why, one step back
69 q = httpx.QueryParams({"a": 1.23})

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 70–71why, one step back
70 assert str(q) == "a=1.23"
71

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 72why, one step back
72 q = httpx.QueryParams({"a": 123})

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 73–74why, one step back
73 assert str(q) == "a=123"
74

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 75why, one step back
75 q = httpx.QueryParams({"a": [1, 2]})

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 76–79why, one step back
76 assert str(q) == "a=1&a=2"
777879def test_queryparam_setters():

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 80why, one step back
80 q = httpx.QueryParams({"a": 1})

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 81–84why, one step back
81 q.update([])
8283 assert str(q) == "a=1"84

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 85why, one step back
85 q = httpx.QueryParams([("a", 1), ("a", 2)])

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 86–88why, one step back
86 q["a"] = "3"
87 assert str(q) == "a=3"88

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

lines 89–90why, one step back
89 q = httpx.QueryParams([("a", 1), ("b", 1)])
90 u = httpx.QueryParams([("b", 2), ("b", 3)])

Revamp proxies documentation (#1123)Florimond Mancabefore adoption70cdd95

lines 91–94why, one step back
91 q.update(u)
9293 assert str(q) == "a=1&b=2&b=3"94 assert q["b"] == u["b"]