MCPcopy
hub / github.com/pallets/flask / test_request_dispatching

Function test_request_dispatching

tests/test_basic.py:131–151  ·  view source on GitHub ↗
(app, client)

Source from the content-addressed store, hash-verified

129
130
131def test_request_dispatching(app, client):
132 @app.route("/")
133 def index():
134 return flask.request.method
135
136 @app.route("/more", methods=["GET", "POST"])
137 def more():
138 return flask.request.method
139
140 assert client.get("/").data == b"GET"
141 rv = client.post("/")
142 assert rv.status_code == 405
143 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS"]
144 rv = client.head("/")
145 assert rv.status_code == 200
146 assert not rv.data # head truncates
147 assert client.post("/more").data == b"POST"
148 assert client.get("/more").data == b"GET"
149 rv = client.delete("/more")
150 assert rv.status_code == 405
151 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]
152
153
154def test_disallow_string_for_allowed_methods(app):

Callers

nothing calls this directly

Calls 4

headMethod · 0.80
getMethod · 0.45
postMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected