| 129 | |
| 130 | |
| 131 | def test_request_dispatching(app, client): |
| 132 | @app.route("/") |
| 133 | def index(): |
| 134 | return flask.request.method |
| 135 | |
| 136 | @app.route("/more", methods=["GET", "POST"]) |
| 137 | def more(): |
| 138 | return flask.request.method |
| 139 | |
| 140 | assert client.get("/").data == b"GET" |
| 141 | rv = client.post("/") |
| 142 | assert rv.status_code == 405 |
| 143 | assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS"] |
| 144 | rv = client.head("/") |
| 145 | assert rv.status_code == 200 |
| 146 | assert not rv.data # head truncates |
| 147 | assert client.post("/more").data == b"POST" |
| 148 | assert client.get("/more").data == b"GET" |
| 149 | rv = client.delete("/more") |
| 150 | assert rv.status_code == 405 |
| 151 | assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"] |
| 152 | |
| 153 | |
| 154 | def test_disallow_string_for_allowed_methods(app): |