Skip to content
Myr

test_queryparams.py

This file

Path

tests/models/test_queryparams.py

92 lines · 2.4 KiB · Python

Last changed by

Version 0.15.0 (#1301)Tom Christiebefore adoptionf932af9

History of this file

Take it

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

Use URLLib3 configuration options for URLLib3 transport (#970)Tom Christiebefore adoption225f1e2

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

Use URLLib3 configuration options for URLLib3 transport (#970)Tom Christiebefore adoption225f1e2

lines 4–14why, 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},12 ],13)14def test_queryparams(source):

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

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

Use URLLib3 configuration options for URLLib3 transport (#970)Tom Christiebefore adoption225f1e2

lines 16–21why, one step back
16 assert "a" in q
17 assert "A" not in q18 assert "c" not in q19 assert q["a"] == "456"20 assert q.get("a") == "456"21 assert q.get("nope", default=None) is None

Consistent multidict methods (#1089)Tom Christiebefore adoption2ba9c1e

line 22why, one step back
22 assert q.get_list("a") == ["123", "456"]

Use get_list consistently (#1119)Tom Christiebefore adoptione5f8743

line 23why, one step back
23

Use URLLib3 configuration options for URLLib3 transport (#970)Tom Christiebefore adoption225f1e2

lines 24–31why, one step back
24 assert list(q.keys()) == ["a", "b"]
25 assert list(q.values()) == ["456", "789"]26 assert list(q.items()) == [("a", "456"), ("b", "789")]27 assert len(q) == 228 assert list(q) == ["a", "b"]29 assert dict(q) == {"a": "456", "b": "789"}30 assert str(q) == "a=123&a=456&b=789"31 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 32why, one step back
32 assert httpx.QueryParams({"a": "123", "b": "456"}) == httpx.QueryParams(

Use URLLib3 configuration options for URLLib3 transport (#970)Tom Christiebefore adoption225f1e2

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

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

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

Use URLLib3 configuration options for URLLib3 transport (#970)Tom Christiebefore adoption225f1e2

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

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

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

Use URLLib3 configuration options for URLLib3 transport (#970)Tom Christiebefore adoption225f1e2

line 46why, one step back
46

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

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

Use URLLib3 configuration options for URLLib3 transport (#970)Tom Christiebefore adoption225f1e2

lines 49–51why, one step back
49
5051def test_queryparam_types():

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

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

Support QueryParams(None) (#1060)Tom Christiebefore adoptionff93a01

lines 53–54why, one step back
53 assert str(q) == ""
54

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

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

Use URLLib3 configuration options for URLLib3 transport (#970)Tom Christiebefore adoption225f1e2

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

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

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

Use URLLib3 configuration options for URLLib3 transport (#970)Tom Christiebefore adoption225f1e2

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

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

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

Use URLLib3 configuration options for URLLib3 transport (#970)Tom Christiebefore adoption225f1e2

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

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

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

Use URLLib3 configuration options for URLLib3 transport (#970)Tom Christiebefore adoption225f1e2

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

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

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

Use URLLib3 configuration options for URLLib3 transport (#970)Tom Christiebefore adoption225f1e2

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

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

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

Use URLLib3 configuration options for URLLib3 transport (#970)Tom Christiebefore adoption225f1e2

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

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

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

Use URLLib3 configuration options for URLLib3 transport (#970)Tom Christiebefore adoption225f1e2

lines 74–77why, one step back
74 assert str(q) == "a=1&a=2"
757677def test_queryparam_setters():

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

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

Use URLLib3 configuration options for URLLib3 transport (#970)Tom Christiebefore adoption225f1e2

lines 79–82why, one step back
79 q.update([])
8081 assert str(q) == "a=1"82

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

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

Use URLLib3 configuration options for URLLib3 transport (#970)Tom Christiebefore adoption225f1e2

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

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

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

Use URLLib3 configuration options for URLLib3 transport (#970)Tom Christiebefore adoption225f1e2

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