| 92 | |
| 93 | |
| 94 | def 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 | |
| 131 | def test_request_dispatching(app, client): |