Skip to content

Commit

Permalink
[#1725] Add tests for when searching/deleting elements passing invali…
Browse files Browse the repository at this point in the history
…d filters
  • Loading branch information
vitorbaptista committed May 22, 2014
1 parent 2c512b1 commit 1a14006
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
18 changes: 18 additions & 0 deletions ckanext/datastore/tests/test_delete.py
Expand Up @@ -156,3 +156,21 @@ def test_delete_filters(self):
self.Session.remove()

self._delete()

def test_delete_is_unsuccessful_when_called_with_invalid_filters(self):
self._create()

data = {
'resource_id': self.data['resource_id'],
'filters': {
'invalid-column-name': 'value'
}
}
postparams = '%s=1' % json.dumps(data)
auth = {'Authorization': str(self.normal_user.apikey)}
res = self.app.post('/api/action/datastore_delete', params=postparams,
extra_environ=auth, status=409)
res_dict = json.loads(res.body)
assert res_dict['success'] is False

self._delete()
14 changes: 14 additions & 0 deletions ckanext/datastore/tests/test_search.py
Expand Up @@ -414,6 +414,20 @@ def test_search_table_metadata(self):
res_dict = json.loads(res.body)
assert res_dict['success'] is True

def test_search_is_unsuccessful_when_called_with_invalid_filters(self):
data = {
'resource_id': self.data['resource_id'],
'filters': {
'invalid-column-name': 'value'
}
}
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, status=409)
res_dict = json.loads(res.body)
assert res_dict['success'] is False


class TestDatastoreFullTextSearch(tests.WsgiAppCase):
@classmethod
Expand Down

0 comments on commit 1a14006

Please sign in to comment.