Skip to content

Commit

Permalink
[#669] Raise NotFound if group is not found in member_list.
Browse files Browse the repository at this point in the history
Allows a proper error to be generated in the API
controller instead of just giving a 500 error.
  • Loading branch information
johnglover committed Mar 20, 2013
1 parent e7ae872 commit 7136819
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ckan/logic/action/get.py
Expand Up @@ -262,6 +262,9 @@ def member_list(context, data_dict=None):
model = context['model']

group = model.Group.get(_get_or_bust(data_dict, 'id'))
if not group:
raise NotFound

obj_type = data_dict.get('object_type', None)
capacity = data_dict.get('capacity', None)

Expand Down
6 changes: 6 additions & 0 deletions ckan/tests/logic/test_member.py
@@ -1,3 +1,5 @@
from nose.tools import assert_raises
import ckan.logic as logic
from ckan import model
from ckan.logic import get_action
from ckan.lib.create_test_data import CreateTestData
Expand Down Expand Up @@ -50,6 +52,10 @@ def test_member_list(self):
res = get_action('member_list')(ctx, dd)
assert len(res) == 0, res

ctx, dd = self._build_context('', 'user', 'admin')
dd['id'] = u'foo'
assert_raises(logic.NotFound, get_action('member_list'), ctx, dd)

self._add_member(self.username, 'user', 'admin')
ctx, dd = self._build_context('', 'user', 'admin')
res = get_action('member_list')(ctx, dd)
Expand Down

0 comments on commit 7136819

Please sign in to comment.