Skip to content
Myr

use header properties

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent 6a2f545 · Browse files · 2 files+6 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+6 added−10 removed

  • tests:+6 added−10 removed

2 files+6 added−10 removed

modified:tests/test_blueprints.py+2 added-5 removed
1import pytest2from jinja2 import TemplateNotFound3from werkzeug.http import parse_cache_control_header34import flask56
191 unmodified lines
198 expected_max_age = 7200199 app.config["SEND_FILE_MAX_AGE_DEFAULT"] = expected_max_age200201 with client.get("/admin/static/css/test.css") as rv:203 cc = parse_cache_control_header(rv.headers["Cache-Control"])204 assert cc.max_age == expected_max_age202 assert rv.cache_control.max_age == expected_max_age203 finally:204 app.config["SEND_FILE_MAX_AGE_DEFAULT"] = max_age_default205206 with app.test_request_context():
21 unmodified lines
228 )229 app.register_blueprint(blueprint)230231 with app.test_request_context(), blueprint.send_static_file("index.html") as rv:234 cc = parse_cache_control_header(rv.headers["Cache-Control"])235 assert cc.max_age == 100232 assert rv.cache_control.max_age == 100233234235def test_templates_list(test_apps):236 from blueprintapp import app
879 unmodified lines
modified:tests/test_views.py+4 added-5 removed
1import pytest2from werkzeug.http import parse_set_header23import flask.views4from flask.testing import FlaskClient5
3 unmodified lines
910 assert c.get("/").data == b"GET"11 assert c.post("/").data == b"POST"12 assert c.put("/").status_code == 40514 meths = parse_set_header(c.open("/", method="OPTIONS").headers["Allow"])15 assert sorted(meths) == ["GET", "HEAD", "OPTIONS", "POST"]13 meths = c.open("/", method="OPTIONS").allow14 assert meths == {"GET", "HEAD", "OPTIONS", "POST"}151617def test_basic_view(app):18 class Index(flask.views.View):
53 unmodified lines
72 return "DELETE"7374 app.add_url_rule("/", view_func=BetterIndex.as_view("index"))7577 meths = parse_set_header(client.open("/", method="OPTIONS").headers["Allow"])78 assert sorted(meths) == ["DELETE", "GET", "HEAD", "OPTIONS", "POST"]76 meths = client.open("/", method="OPTIONS").allow77 assert meths == {"DELETE", "GET", "HEAD", "OPTIONS", "POST"}787980def test_view_decorators(app, client):81 def add_x_parachute(f):
190 unmodified lines