mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
Warcserver / CDXJ API: properly handle unsupported output formats (#623)
- add unit test to verify unknown output formats are handled if output fields param is in request
This commit is contained in:
parent
4224cdd7e5
commit
c62b1bc987
@ -86,7 +86,7 @@ class IndexHandler(object):
|
||||
if fields and isinstance(fields, str):
|
||||
fields = fields.split(',')
|
||||
|
||||
handler = self.OUTPUTS.get(output, fields)
|
||||
handler = self.OUTPUTS.get(output)
|
||||
if not handler:
|
||||
errs = dict(last_exc=BadRequestException('output={0} not supported'.format(output)))
|
||||
return None, None, errs
|
||||
|
@ -287,5 +287,13 @@ class TestCDXApp(BaseTestClass):
|
||||
for i in range(len(cdxes) - 1):
|
||||
assert cdxes[i]['timestamp'] >= cdxes[i + 1]['timestamp']
|
||||
|
||||
def test_error_unknown_output_format(self):
|
||||
"""test unknown output format in combination with a list of output fields"""
|
||||
resp = self.query('http://www.iana.org/_css/2013.1/print.css',
|
||||
is_error=True,
|
||||
fields='urlkey,timestamp,status',
|
||||
output='foo')
|
||||
assert resp.status_code == 400
|
||||
assert resp.json == {'message': 'output=foo not supported'}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user