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

Function test_url_mapping

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

Source from the content-addressed store, hash-verified

157
158
159def test_url_mapping(app, client):
160 random_uuid4 = "7eb41166-9ebf-4d26-b771-ea3f54f8b383"
161
162 def index():
163 return flask.request.method
164
165 def more():
166 return flask.request.method
167
168 def options():
169 return random_uuid4
170
171 app.add_url_rule("/", "index", index)
172 app.add_url_rule("/more", "more", more, methods=["GET", "POST"])
173
174 # Issue 1288: Test that automatic options are not added
175 # when non-uppercase 'options' in methods
176 app.add_url_rule("/options", "options", options, methods=["options"])
177
178 assert client.get("/").data == b"GET"
179 rv = client.post("/")
180 assert rv.status_code == 405
181 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS"]
182 rv = client.head("/")
183 assert rv.status_code == 200
184 assert not rv.data # head truncates
185 assert client.post("/more").data == b"POST"
186 assert client.get("/more").data == b"GET"
187 rv = client.delete("/more")
188 assert rv.status_code == 405
189 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]
190 rv = client.open("/options", method="OPTIONS")
191 assert rv.status_code == 200
192 assert random_uuid4 in rv.data.decode("utf-8")
193
194
195def test_werkzeug_routing(app, client):

Callers

nothing calls this directly

Calls 6

headMethod · 0.80
openMethod · 0.80
add_url_ruleMethod · 0.45
getMethod · 0.45
postMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…