forked from orbit-oss/flask
style cleanup
break out header parts in test test for no filename* parameter for ascii header
This commit is contained in:
parent
d50a5db5ed
commit
c1973016ea
2 changed files with 28 additions and 16 deletions
|
|
@ -540,10 +540,11 @@ class TestSendfile(object):
|
|||
value, options = \
|
||||
parse_options_header(rv.headers['Content-Disposition'])
|
||||
assert value == 'attachment'
|
||||
assert options['filename'] == 'index.html'
|
||||
assert 'filename*' not in options
|
||||
rv.close()
|
||||
|
||||
with app.test_request_context():
|
||||
assert options['filename'] == 'index.html'
|
||||
rv = flask.send_file('static/index.html', as_attachment=True)
|
||||
value, options = parse_options_header(rv.headers['Content-Disposition'])
|
||||
assert value == 'attachment'
|
||||
|
|
@ -562,15 +563,21 @@ class TestSendfile(object):
|
|||
|
||||
def test_attachment_with_utf8_filename(self):
|
||||
app = flask.Flask(__name__)
|
||||
|
||||
with app.test_request_context():
|
||||
with open(os.path.join(app.root_path, 'static/index.html')) as f:
|
||||
rv = flask.send_file(f, as_attachment=True,
|
||||
attachment_filename=u'Ñandú/pingüino.txt')
|
||||
content_disposition = set(rv.headers['Content-Disposition'].split(';'))
|
||||
assert content_disposition == set(['attachment',
|
||||
' filename="Nandu/pinguino.txt"',
|
||||
" filename*=UTF-8''%C3%91and%C3%BA%EF%BC%8Fping%C3%BCino.txt"])
|
||||
rv.close()
|
||||
rv = flask.send_file(
|
||||
'static/index.html', as_attachment=True,
|
||||
attachment_filename=u'Ñandú/pingüino.txt'
|
||||
)
|
||||
value, options = parse_options_header(
|
||||
rv.headers['Content-Disposition']
|
||||
)
|
||||
rv.close()
|
||||
|
||||
assert value == 'attachment'
|
||||
assert sorted(options.keys()) == ('filename', 'filename*')
|
||||
assert options['filename'] == 'Nandu/pinguino.txt'
|
||||
assert options['filename*'] == 'UTF-8''%C3%91and%C3%BA%EF%BC%8Fping%C3%BCino.txt'
|
||||
|
||||
def test_static_file(self):
|
||||
app = flask.Flask(__name__)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue