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

Function test_url_mapping

tests/test_basic.py:159–192  ·  tests/test_basic.py::test_url_mapping
(app, client)

Source from the content-addressed store, hash-verified

157
158
159def test_url_mapping(app, client):
160 random_uuid4 = class="st">"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(class="st">"/", class="st">"index", index)
172 app.add_url_rule(class="st">"/more", class="st">"more", more, methods=[class="st">"GET", class="st">"POST"])
173
174 class="cm"># Issue 1288: Test that automatic options are not added
175 class="cm"># when non-uppercase class="st">'options' in methods
176 app.add_url_rule(class="st">"/options", class="st">"options", options, methods=[class="st">"options"])
177
178 assert client.get(class="st">"/").data == bclass="st">"GET"
179 rv = client.post(class="st">"/")
180 assert rv.status_code == 405
181 assert sorted(rv.allow) == [class="st">"GET", class="st">"HEAD", class="st">"OPTIONS"]
182 rv = client.head(class="st">"/")
183 assert rv.status_code == 200
184 assert not rv.data class="cm"># head truncates
185 assert client.post(class="st">"/more").data == bclass="st">"POST"
186 assert client.get(class="st">"/more").data == bclass="st">"GET"
187 rv = client.delete(class="st">"/more")
188 assert rv.status_code == 405
189 assert sorted(rv.allow) == [class="st">"GET", class="st">"HEAD", class="st">"OPTIONS", class="st">"POST"]
190 rv = client.open(class="st">"/options", method=class="st">"OPTIONS")
191 assert rv.status_code == 200
192 assert random_uuid4 in rv.data.decode(class="st">"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