Skip to content

Commit

Permalink
[#1251] Test that the DataStore supports filtering by multiple values
Browse files Browse the repository at this point in the history
It doesn't currently, that's why I created issue #1830.
  • Loading branch information
vitorbaptista committed Jul 2, 2014
1 parent 5b30e19 commit fc29b6e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion ckanext/datastore/tests/test_search.py
Expand Up @@ -211,7 +211,7 @@ def test_search_filters(self):
assert result['total'] == 1
assert result['records'] == [self.expected_records[0]]

def test_search_array_filters(self):
def test_search_filter_array_field(self):
data = {'resource_id': self.data['resource_id'],
'filters': {u'characters': [u'Princess Anna', u'Sergius']}}
postparams = '%s=1' % json.dumps(data)
Expand All @@ -224,6 +224,19 @@ def test_search_array_filters(self):
assert result['total'] == 1
assert result['records'] == [self.expected_records[0]]

def test_search_filter_normal_field_passing_multiple_values_in_array(self):
data = {'resource_id': self.data['resource_id'],
'filters': {u'b\xfck': [u'annakarenina', u'warandpeace']}}
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 result['total'] == 2
assert result['records'] == self.expected_records, result['records']

def test_search_filters_get(self):
filters = {u'b\xfck': 'annakarenina'}
res = self.app.get('/api/action/datastore_search?resource_id={0}&filters={1}'.format(
Expand Down

0 comments on commit fc29b6e

Please sign in to comment.