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

Function test_provide_automatic_options_kwarg

tests/test_basic.py:94–128  ·  view source on GitHub ↗
(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("/", view_func=index, provide_automatic_options=False)
102 app.add_url_rule(
103 "/more",
104 view_func=more,
105 methods=["GET", "POST"],
106 provide_automatic_options=False,
107 )
108 assert client.get("/").data == b"GET"
109
110 rv = client.post("/")
111 assert rv.status_code == 405
112 assert sorted(rv.allow) == ["GET", "HEAD"]
113
114 rv = client.open("/", method="OPTIONS")
115 assert rv.status_code == 405
116
117 rv = client.head("/")
118 assert rv.status_code == 200
119 assert not rv.data # head truncates
120 assert client.post("/more").data == b"POST"
121 assert client.get("/more").data == b"GET"
122
123 rv = client.delete("/more")
124 assert rv.status_code == 405
125 assert sorted(rv.allow) == ["GET", "HEAD", "POST"]
126
127 rv = client.open("/more", method="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

Used in the wild real call sites across dependent graphs

searching dependent graphs…