MCPcopy
hub / github.com/pallets/werkzeug / test_base_request

Function test_base_request

tests/test_wrappers.py:53–97  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

51
52
53def test_base_request():
54 client = Client(request_demo_app)
55
56 # get requests
57 response = client.get("/?foo=bar&foo=hehe")
58 request = response.request
59 assert request.args == MultiDict([("foo", "bar"), ("foo", "hehe")])
60 assert request.form == MultiDict()
61 assert request.data == b""
62 assert_environ(request.environ, "GET")
63
64 # post requests with form data
65 response = client.post(
66 "/?blub=blah",
67 data="foo=blub+hehe&blah=42",
68 content_type="application/x-www-form-urlencoded",
69 )
70 request = response.request
71 assert request.args == MultiDict([("blub", "blah")])
72 assert request.form == MultiDict([("foo", "blub hehe"), ("blah", "42")])
73 assert request.data == b""
74 # currently we do not guarantee that the values are ordered correctly
75 # for post data.
76 # assert response['form_as_list'] == [('foo', ['blub hehe']), ('blah', ['42'])]
77 assert_environ(request.environ, "POST")
78
79 # patch requests with form data
80 response = client.patch(
81 "/?blub=blah",
82 data="foo=blub+hehe&blah=42",
83 content_type="application/x-www-form-urlencoded",
84 )
85 request = response.request
86 assert request.args == MultiDict([("blub", "blah")])
87 assert request.form == MultiDict([("foo", "blub hehe"), ("blah", "42")])
88 assert request.data == b""
89 assert_environ(request.environ, "PATCH")
90
91 # post requests with json data
92 json = b'{"foo": "bar", "blub": "blah"}'
93 response = client.post("/?a=b", data=json, content_type="application/json")
94 request = response.request
95 assert request.data == json
96 assert request.args == MultiDict([("a", "b")])
97 assert request.form == MultiDict()
98
99
100def test_query_string_is_bytes():

Callers

nothing calls this directly

Calls 6

getMethod · 0.95
postMethod · 0.95
patchMethod · 0.95
ClientClass · 0.90
MultiDictClass · 0.90
assert_environFunction · 0.85

Tested by

no test coverage detected