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

Function test_provide_automatic_options_kwarg

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

Source from the content-addressed store, hash-verified

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