Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
David Read authored and smotornyuk committed Jun 16, 2019
1 parent 0bc3ad6 commit 2ad9d50
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ckanext/datastore/controller.py
Expand Up @@ -139,7 +139,7 @@ def result_page(offs, lim):
'offset': offs,
'sort': '_id',
'records_format': records_format,
'include_total': 'false',
'include_total': False,
})

result = result_page(offset, limit)
Expand Down
29 changes: 17 additions & 12 deletions ckanext/datastore/tests/test_search.py
Expand Up @@ -100,6 +100,23 @@ def test_all_params_work_with_fields_with_whitespaces(self):
result_years = [r['the year'] for r in result['records']]
assert_equals(result_years, [2013])

def test_search_without_total(self):
resource = factories.Resource()
data = {
'resource_id': resource['id'],
'force': True,
'records': [
{'the year': 2014},
{'the year': 2013},
],
}
result = helpers.call_action('datastore_create', **data)
search_data = {
'resource_id': resource['id'],
'include_total': False
}
result = helpers.call_action('datastore_search', **search_data)
assert 'total' not in result


class TestDatastoreSearch(DatastoreLegacyTestBase):
Expand Down Expand Up @@ -634,18 +651,6 @@ def test_search_is_unsuccessful_when_called_with_invalid_fields(self):
assert res_dict['success'] is False
assert res_dict['error'].get('fields') is not None, res_dict['error']

def test_search_without_total(self):
data = {'resource_id': self.data['resource_id'],
'include_total': False}
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 True
result = res_dict['result']
assert 'total' not in result


class TestDatastoreFullTextSearch(DatastoreLegacyTestBase):
@classmethod
Expand Down

0 comments on commit 2ad9d50

Please sign in to comment.