Skip to content

Commit

Permalink
[#621] Return duplicate extras key error in a list
Browse files Browse the repository at this point in the history
This makes it consistent with other errors that CKAN returns.
  • Loading branch information
Sean Hammond committed Apr 10, 2013
1 parent ed0b852 commit bcff15a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ckan/logic/validators.py
Expand Up @@ -315,7 +315,7 @@ def duplicate_extras_key(key, data, errors, context):
if extras_keys:
key_ = ('extras_validation',)
assert key_ not in errors
errors[key_] = _('Duplicate key "%s"') % extras_keys[0]
errors[key_] = [_('Duplicate key "%s"') % extras_keys[0]]

def group_name_validator(key, data, errors, context):
model = context['model']
Expand Down
4 changes: 2 additions & 2 deletions ckan/tests/logic/test_action.py
Expand Up @@ -1145,7 +1145,7 @@ def test_package_create_duplicate_extras_error(self):
name='foobar', extras=[{'key': 'foo', 'value': 'bar'},
{'key': 'foo', 'value': 'gar'}])
assert error['__type'] == 'Validation Error'
assert error['extras_validation'] == 'Duplicate key "foo"'
assert error['extras_validation'] == ['Duplicate key "foo"']

def test_package_update_duplicate_extras_error(self):
import ckan.tests
Expand All @@ -1164,7 +1164,7 @@ def test_package_update_duplicate_extras_error(self):
error = ckan.tests.call_action_api(app, 'package_update',
apikey=self.sysadmin_user.apikey, status=409, **package)
assert error['__type'] == 'Validation Error'
assert error['extras_validation'] == 'Duplicate key "foo"'
assert error['extras_validation'] == ['Duplicate key "foo"']

class TestActionTermTranslation(WsgiAppCase):

Expand Down

0 comments on commit bcff15a

Please sign in to comment.