Skip to content

Commit

Permalink
\#3189 Datastore doesn't add site_url to resource created via API
Browse files Browse the repository at this point in the history
Small change in datastore plugin, that generates
fully-qualified url during datastore creation
  • Loading branch information
smotornyuk committed Nov 29, 2016
1 parent 82a12f2 commit 0b0454c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ckanext/datapusher/tests/test.py
Expand Up @@ -96,7 +96,7 @@ def test_create_ckan_resource_in_package(self):

res = tests.call_action_api(
self.app, 'resource_show', id=res_dict['result']['resource_id'])
assert res['url'] == '/datastore/dump/' + res['id'], res
assert res['url'].endswith('/datastore/dump/' + res['id']), res

@httpretty.activate
def test_providing_res_with_url_calls_datapusher_correctly(self):
Expand Down
3 changes: 2 additions & 1 deletion ckanext/datastore/plugin.py
Expand Up @@ -257,7 +257,8 @@ def before_show(self, resource_dict):
if resource_dict.get('url_type') == 'datastore':
resource_dict['url'] = p.toolkit.url_for(
controller='ckanext.datastore.controller:DatastoreController',
action='dump', resource_id=resource_dict['id'])
action='dump', resource_id=resource_dict['id'],
qualified=True)

if 'datastore_active' not in resource_dict:
resource_dict[u'datastore_active'] = False
Expand Down
14 changes: 14 additions & 0 deletions ckanext/datastore/tests/test_create.py
Expand Up @@ -45,6 +45,20 @@ def test_create_creates_index_on_primary_key(self):
index_names = self._get_index_names(resource_id)
assert resource_id + '_pkey' in index_names

def test_create_creates_url_with_site_name(self):
package = factories.Dataset()
data = {
'resource': {
'boo%k': 'crime',
'package_id': package['id']
},
}
result = helpers.call_action('datastore_create', **data)
resource_id = result['resource_id']
resource = helpers.call_action('resource_show', id=resource_id)
url = resource['url']
assert url.startswith(config.get('ckan.site_url'))

def test_create_index_on_specific_fields(self):
package = factories.Dataset()
data = {
Expand Down

0 comments on commit 0b0454c

Please sign in to comment.