Skip to content

Commit

Permalink
need to test against raw header
Browse files Browse the repository at this point in the history
parsing prefers the last value parsed for the option
  • Loading branch information
davidism committed Apr 8, 2017
1 parent c197301 commit f790ab7
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def test_attachment(self):
parse_options_header(rv.headers['Content-Disposition'])
assert value == 'attachment'
assert options['filename'] == 'index.html'
assert 'filename*' not in options
assert 'filename*' not in rv.headers['Content-Disposition']
rv.close()

with app.test_request_context():
Expand All @@ -565,20 +565,15 @@ def test_attachment_with_utf8_filename(self):
app = flask.Flask(__name__)

with app.test_request_context():
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 = flask.send_file('static/index.html', 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()

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__)
# default cache timeout is 12 hours
Expand Down

0 comments on commit f790ab7

Please sign in to comment.