Skip to content

Commit

Permalink
@Natim review
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed Oct 19, 2016
1 parent df488a4 commit 86b9813
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cornice/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def add(self, location, name=None, description=None, **kw):
"""Registers a new error."""
allowed = ('body', 'querystring', 'url', 'header', 'path',
'cookies', 'method')
if location not in allowed:
if location != '' and location not in allowed:
raise ValueError('%r not in %s' % (location, allowed))

self.append(dict(
Expand Down
11 changes: 11 additions & 0 deletions cornice/tests/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ class TestErrorsHelper(TestCase):
def setUp(self):
self.errors = Errors()

def test_add_to_supported_location(self):
self.errors.add('')
self.errors.add('body', description='!')
self.errors.add('querystring', name='field')
self.errors.add('url')
self.errors.add('header')
self.errors.add('path')
self.errors.add('cookies')
self.errors.add('method')
self.assertEqual(len(self.errors), 8)

def test_raises_an_exception_when_location_is_unsupported(self):
with self.assertRaises(ValueError):
self.errors.add('something')

0 comments on commit 86b9813

Please sign in to comment.