Skip to content

Commit

Permalink
[ckan#3120] Format abort message with key
Browse files Browse the repository at this point in the history
  • Loading branch information
brew committed Jul 14, 2016
1 parent 5ce8284 commit a476eb2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion ckan/lib/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,8 @@ def get_page_number(params, key='page', default=1):
raise ValueError("Negative number not allowed")
except ValueError:
import ckan.lib.base as base
base.abort(400, ('"{key}" parameter must be a positive integer'))
base.abort(400, ('"{key}" parameter must be a positive integer'
.format(key=key)))

return p

Expand Down
6 changes: 3 additions & 3 deletions ckan/tests/controllers/test_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ def test_atom_feed_page_zero_gives_error(self):
id=group['name']) + '?page=0'
app = self._get_test_app()
res = app.get(offset, status=400)
assert '"{key}" parameter must be a positive integer' in res, res
assert '"page" parameter must be a positive integer' in res, res

def test_atom_feed_page_negative_gives_error(self):
group = factories.Group()
offset = url_for(controller='feed', action='group',
id=group['name']) + '?page=-2'
app = self._get_test_app()
res = app.get(offset, status=400)
assert '"{key}" parameter must be a positive integer' in res, res
assert '"page" parameter must be a positive integer' in res, res

def test_atom_feed_page_not_int_gives_error(self):
group = factories.Group()
offset = url_for(controller='feed', action='group',
id=group['name']) + '?page=abc'
app = self._get_test_app()
res = app.get(offset, status=400)
assert '"{key}" parameter must be a positive integer' in res, res
assert '"page" parameter must be a positive integer' in res, res

0 comments on commit a476eb2

Please sign in to comment.