()
| 99 | |
| 100 | |
| 101 | def test_view_provide_automatic_options_attr(): |
| 102 | app = flask.Flask(__name__) |
| 103 | |
| 104 | class Index1(flask.views.View): |
| 105 | provide_automatic_options = False |
| 106 | |
| 107 | def dispatch_request(self): |
| 108 | return "Hello World!" |
| 109 | |
| 110 | app.add_url_rule("/", view_func=Index1.as_view("index")) |
| 111 | c = app.test_client() |
| 112 | rv = c.open("/", method="OPTIONS") |
| 113 | assert rv.status_code == 405 |
| 114 | |
| 115 | app = flask.Flask(__name__) |
| 116 | |
| 117 | class Index2(flask.views.View): |
| 118 | methods = ["OPTIONS"] |
| 119 | provide_automatic_options = True |
| 120 | |
| 121 | def dispatch_request(self): |
| 122 | return "Hello World!" |
| 123 | |
| 124 | app.add_url_rule("/", view_func=Index2.as_view("index")) |
| 125 | c = app.test_client() |
| 126 | rv = c.open("/", method="OPTIONS") |
| 127 | assert sorted(rv.allow) == ["OPTIONS"] |
| 128 | |
| 129 | app = flask.Flask(__name__) |
| 130 | |
| 131 | class Index3(flask.views.View): |
| 132 | def dispatch_request(self): |
| 133 | return "Hello World!" |
| 134 | |
| 135 | app.add_url_rule("/", view_func=Index3.as_view("index")) |
| 136 | c = app.test_client() |
| 137 | rv = c.open("/", method="OPTIONS") |
| 138 | assert "OPTIONS" in rv.allow |
| 139 | |
| 140 | |
| 141 | def test_implicit_head(app, client): |
nothing calls this directly
no test coverage detected