MCPcopy Create free account
hub / github.com/pallets/flask / test_request_dispatching

Function test_request_dispatching

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

Source from the content-addressed store, hash-verified

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