automatic options as separate route
This commit is contained in:
parent
dcbede0cb0
commit
80669a0ea8
5 changed files with 56 additions and 30 deletions
|
|
@ -52,6 +52,13 @@ def test_options_on_multiple_rules(app, client):
|
|||
assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST", "PUT"]
|
||||
|
||||
|
||||
def test_options_view_args(app: flask.Flask, client: FlaskClient) -> None:
|
||||
"""The automatic options view accepts any view args."""
|
||||
app.add_url_rule("/<a>/<b>", endpoint="add")
|
||||
rv = client.options("/1/2")
|
||||
assert rv.allow == {"GET", "HEAD", "OPTIONS"}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("method", ["get", "post", "put", "delete", "patch"])
|
||||
def test_method_route(app, client, method):
|
||||
method_route = getattr(app, method)
|
||||
|
|
|
|||
|
|
@ -483,12 +483,17 @@ class TestRoutes:
|
|||
["yyy_get_post", "static", "aaa_post"],
|
||||
invoke(["routes", "-s", "rule"]).output,
|
||||
)
|
||||
match_order = [r.endpoint for r in app.url_map.iter_rules()]
|
||||
match_order = [
|
||||
r.endpoint
|
||||
for r in app.url_map.iter_rules()
|
||||
if r.endpoint != "_automatic_options"
|
||||
]
|
||||
self.expect_order(match_order, invoke(["routes", "-s", "match"]).output)
|
||||
|
||||
def test_all_methods(self, invoke):
|
||||
output = invoke(["routes"]).output
|
||||
assert "GET, HEAD, OPTIONS, POST" not in output
|
||||
assert "HEAD" not in output
|
||||
assert "OPTIONS" not in output
|
||||
|
||||
output = invoke(["routes", "--all-methods"]).output
|
||||
assert "GET, HEAD, OPTIONS, POST" in output
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue