test_queryparams.py
This file
Path
tests/models/test_queryparams.py
94 lines · 2.5 KiB · Python
Last changed by
Allow tuple as input of query parameters. (#1426)SarunasAznabefore adoption8696405
History of this fileTake it
The walk stopped after 200 commits: lines older than 31e587c point at it.
Pin pytestTom Christiebefore adoption31e587c
lines 1–2why, one step back1import pytest2Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 3why, one step back3import httpxPin pytestTom Christiebefore adoption31e587c
lines 4–11why, one step back456@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 back12 [("a", "123"), ("a", "456"), ("b", "789")],13 (("a", "123"), ("a", "456"), ("b", "789")),Pin pytestTom Christiebefore adoption31e587c
lines 14–16why, one step back14 ],15)16def test_queryparams(source):Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 17why, one step back17 q = httpx.QueryParams(source)Pin pytestTom Christiebefore adoption31e587c
lines 18–23why, one step back18 assert "a" in q19 assert "A" not in q20 assert "c" not in q21 assert q["a"] == "456"22 assert q.get("a") == "456"23 assert q.get("nope", default=None) is NoneConsistent multidict methods (#1089)Tom Christiebefore adoption2ba9c1e
line 24why, one step back24 assert q.get_list("a") == ["123", "456"]Use get_list consistently (#1119)Tom Christiebefore adoptione5f8743
line 25why, one step back25Pin pytestTom Christiebefore adoption31e587c
lines 26–33why, one step back26 assert list(q.keys()) == ["a", "b"]27 assert list(q.values()) == ["456", "789"]28 assert list(q.items()) == [("a", "456"), ("b", "789")]29 assert len(q) == 230 assert list(q) == ["a", "b"]31 assert dict(q) == {"a": "456", "b": "789"}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 back34 assert httpx.QueryParams({"a": "123", "b": "456"}) == httpx.QueryParams(Pin pytestTom Christiebefore adoption31e587c
lines 35–36why, one step back35 [("a", "123"), ("b", "456")]36 )Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
lines 37–40why, one step back37 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(Pin pytestTom Christiebefore adoption31e587c
lines 41–42why, one step back41 {"b": "456", "a": "123"}42 )Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
lines 43–47why, one step back43 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"Pin pytestTom Christiebefore adoption31e587c
line 48why, one step back48Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
lines 49–50why, one step back49 q = httpx.QueryParams([("a", "123"), ("a", "456")])50 assert httpx.QueryParams(q) == qPin pytestTom Christiebefore adoption31e587c
lines 51–53why, one step back515253def test_queryparam_types():Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 54why, one step back54 q = httpx.QueryParams(None)Pin pytestTom Christiebefore adoption31e587c
lines 55–56why, one step back55 assert str(q) == ""56Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 57why, one step back57 q = httpx.QueryParams({"a": True})Pin pytestTom Christiebefore adoption31e587c
lines 58–59why, one step back58 assert str(q) == "a=true"59Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 60why, one step back60 q = httpx.QueryParams({"a": False})Pin pytestTom Christiebefore adoption31e587c
lines 61–62why, one step back61 assert str(q) == "a=false"62Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 63why, one step back63 q = httpx.QueryParams({"a": ""})Pin pytestTom Christiebefore adoption31e587c
lines 64–65why, one step back64 assert str(q) == "a="65Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 66why, one step back66 q = httpx.QueryParams({"a": None})Pin pytestTom Christiebefore adoption31e587c
lines 67–68why, one step back67 assert str(q) == "a="68Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 69why, one step back69 q = httpx.QueryParams({"a": 1.23})Pin pytestTom Christiebefore adoption31e587c
lines 70–71why, one step back70 assert str(q) == "a=1.23"71Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 72why, one step back72 q = httpx.QueryParams({"a": 123})Pin pytestTom Christiebefore adoption31e587c
lines 73–74why, one step back73 assert str(q) == "a=123"74Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 75why, one step back75 q = httpx.QueryParams({"a": [1, 2]})Pin pytestTom Christiebefore adoption31e587c
lines 76–79why, one step back76 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 back80 q = httpx.QueryParams({"a": 1})Pin pytestTom Christiebefore adoption31e587c
lines 81–84why, one step back81 q.update([])8283 assert str(q) == "a=1"84Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 85why, one step back85 q = httpx.QueryParams([("a", 1), ("a", 2)])Pin pytestTom Christiebefore adoption31e587c
lines 86–88why, one step back86 q["a"] = "3"87 assert str(q) == "a=3"88Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
lines 89–90why, one step back89 q = httpx.QueryParams([("a", 1), ("b", 1)])90 u = httpx.QueryParams([("b", 2), ("b", 3)])Pin pytestTom Christiebefore adoption31e587c
lines 91–94why, one step back91 q.update(u)9293 assert str(q) == "a=1&b=2&b=3"94 assert q["b"] == u["b"]