Skip to content

Commit

Permalink
[#652][wip] Add test for search for private datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Apr 18, 2013
1 parent db1d6a6 commit c3f3e0b
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion ckanext/datastore/tests/test_search.py
Expand Up @@ -97,10 +97,34 @@ def test_search_basic(self):
assert result['total'] == len(self.data['records'])
assert result['records'] == self.expected_records, result['records']

def test_search_private_dataset(self):
group = self.dataset.get_groups()[0]
context = {
'user': self.sysadmin_user.name,
'model': model}
p.toolkit.get_action('bulk_update_private')(
context,
{'datasets': [self.dataset.id],
'org_id': group.id})
p.toolkit.get_action('member_delete')(
context,
{'object': self.normal_user.id,
'id': group.id,
'object_type': 'user'})
#self.dataset = model.Package.get('annakarenina')
#print self.dataset
data = {'resource_id': self.data['resource_id']}
postparams = '%s=1' % json.dumps(data)
auth = {'Authorization': str(self.normal_user.apikey)}
res = self.app.post('/api/action/datastore_search', params=postparams,
extra_environ=auth)
res_dict = json.loads(res.body)
assert res_dict['success'] is False

def test_search_alias(self):
data = {'resource_id': self.data['aliases']}
postparams = '%s=1' % json.dumps(data)
auth = {'Authorization': str(self.sysadmin_user.apikey)}
auth = {'Authorization': str(self.normal_user.apikey)}
res = self.app.post('/api/action/datastore_search', params=postparams,
extra_environ=auth)
res_dict_alias = json.loads(res.body)
Expand Down

0 comments on commit c3f3e0b

Please sign in to comment.