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

Function test_provide_automatic_options_kwarg

tests/test_basic.py:94–128  ·  tests/test_basic.py::test_provide_automatic_options_kwarg
(app, client)

Source from the content-addressed store, hash-verified

92
93
94def test_provide_automatic_options_kwarg(app, client):
95 def index():
96 return flask.request.method
97
98 def more():
99 return flask.request.method
100
101 app.add_url_rule(class="st">"/", view_func=index, provide_automatic_options=False)
102 app.add_url_rule(
103 class="st">"/more",
104 view_func=more,
105 methods=[class="st">"GET", class="st">"POST"],
106 provide_automatic_options=False,
107 )
108 assert client.get(class="st">"/").data == bclass="st">"GET"
109
110 rv = client.post(class="st">"/")
111 assert rv.status_code == 405
112 assert sorted(rv.allow) == [class="st">"GET", class="st">"HEAD"]
113
114 rv = client.open(class="st">"/", method=class="st">"OPTIONS")
115 assert rv.status_code == 405
116
117 rv = client.head(class="st">"/")
118 assert rv.status_code == 200
119 assert not rv.data class="cm"># head truncates
120 assert client.post(class="st">"/more").data == bclass="st">"POST"
121 assert client.get(class="st">"/more").data == bclass="st">"GET"
122
123 rv = client.delete(class="st">"/more")
124 assert rv.status_code == 405
125 assert sorted(rv.allow) == [class="st">"GET", class="st">"HEAD", class="st">"POST"]
126
127 rv = client.open(class="st">"/more", method=class="st">"OPTIONS")
128 assert rv.status_code == 405
129
130
131def test_request_dispatching(app, client):

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected