diff --git a/ckanext/datastore/tests/test_create.py b/ckanext/datastore/tests/test_create.py index 6ee8e21d9f5..4fd7da6b48c 100644 --- a/ckanext/datastore/tests/test_create.py +++ b/ckanext/datastore/tests/test_create.py @@ -453,6 +453,20 @@ def test_create_basic(self): assert res_dict['success'] is True, res_dict + ####### insert with paramter id rather than resource_id which is a shortcut + data8 = { + 'id': resource.id, + 'records': [{'boo%k': 'warandpeace'}] + } + + postparams = '%s=1' % json.dumps(data8) + auth = {'Authorization': str(self.sysadmin_user.apikey)} + res = self.app.post('/api/action/datastore_create', params=postparams, + extra_environ=auth, expect_errors=True) + res_dict = json.loads(res.body) + + assert res_dict['success'] is True, res_dict + def test_guess_types(self): resource = model.Package.get('annakarenina').resources[1] diff --git a/ckanext/datastore/tests/test_delete.py b/ckanext/datastore/tests/test_delete.py index 0649510687a..41a43431d5e 100644 --- a/ckanext/datastore/tests/test_delete.py +++ b/ckanext/datastore/tests/test_delete.py @@ -134,8 +134,8 @@ def test_delete_filters(self): assert results[0].book == 'annakarenina' self.Session.remove() - # delete the 'annakarenina' row - data = {'resource_id': resource_id, + # delete the 'annakarenina' row and also only use id + data = {'id': resource_id, 'filters': {'book': 'annakarenina', 'author': 'tolstoy'}} postparams = '%s=1' % json.dumps(data) auth = {'Authorization': str(self.sysadmin_user.apikey)} diff --git a/ckanext/datastore/tests/test_search.py b/ckanext/datastore/tests/test_search.py index 6f80fd49955..36fe8556a31 100644 --- a/ckanext/datastore/tests/test_search.py +++ b/ckanext/datastore/tests/test_search.py @@ -80,6 +80,18 @@ def test_search_basic(self): assert result['total'] == len(self.data['records']) assert result['records'] == self.expected_records, result['records'] + # search with parameter id should yield the same results + data = {'id': self.data['resource_id']} + postparams = '%s=1' % json.dumps(data) + auth = {'Authorization': str(self.sysadmin_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'] == len(self.data['records']) + assert result['records'] == self.expected_records, result['records'] + def test_search_alias(self): data = {'resource_id': self.data['aliases']} postparams = '%s=1' % json.dumps(data)