mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-25 00:12:08 +08:00
Allow anonymous downloading of test-data files
This commit is contained in:
@@ -129,6 +129,23 @@ class ToolsController(BaseAPIController, UsesVisualizationMixin):
|
||||
else:
|
||||
raise exceptions.ObjectNotFound("Specified test data path not found.")
|
||||
|
||||
@expose_api_raw_anonymous_and_sessionless
|
||||
def test_data_download(self, trans, id, **kwd):
|
||||
"""
|
||||
GET /api/tools/{tool_id}/test_data_download?tool_version={tool_version}&filename={filename}
|
||||
"""
|
||||
tool_version = kwd.get('tool_version', None)
|
||||
tool = self._get_tool(id, tool_version=tool_version, user=trans.user)
|
||||
filename = kwd.get("filename")
|
||||
if filename is None:
|
||||
raise exceptions.ObjectNotFound("Test data filename not specified.")
|
||||
path = tool.test_data_path(filename)
|
||||
if path:
|
||||
trans.response.headers["Content-Disposition"] = 'attachment; filename="%s"' % filename
|
||||
return open(path, mode='rb')
|
||||
else:
|
||||
raise exceptions.ObjectNotFound("Specified test data path not found.")
|
||||
|
||||
@expose_api_anonymous_and_sessionless
|
||||
def tests_summary(self, trans, **kwd):
|
||||
"""
|
||||
|
||||
@@ -324,6 +324,7 @@ def populate_api_routes(webapp, app):
|
||||
webapp.mapper.connect('/api/tools/{id:.+?}/reload', action='reload', controller="tools")
|
||||
webapp.mapper.connect('/api/tools/tests_summary', action='tests_summary', controller="tools")
|
||||
webapp.mapper.connect('/api/tools/{id:.+?}/test_data_path', action='test_data_path', controller="tools")
|
||||
webapp.mapper.connect('/api/tools/{id:.+?}/test_data_download', action='test_data_download', controller="tools")
|
||||
webapp.mapper.connect('/api/tools/{id:.+?}/test_data', action='test_data', controller="tools")
|
||||
webapp.mapper.connect('/api/tools/{id:.+?}/diagnostics', action='diagnostics', controller="tools")
|
||||
webapp.mapper.connect('/api/tools/{id:.+?}/citations', action='citations', controller="tools")
|
||||
|
||||
@@ -221,6 +221,11 @@ class ToolsTestCase(api.ApiTestCase):
|
||||
test_data = test_data_response.json()
|
||||
assert len(test_data) == 3
|
||||
|
||||
@skip_without_tool("cat1")
|
||||
def test_test_data_download(self):
|
||||
test_data_response = self._get("tools/%s/test_data_download?filename=1.bed" % "cat1")
|
||||
assert test_data_response.status_code == 200, test_data_response.text.startswith('chr')
|
||||
|
||||
@uses_test_history(require_new=False)
|
||||
def test_upload_composite_as_tar(self, history_id):
|
||||
tar_path = self.test_data_resolver.get_filename("testdir.tar")
|
||||
|
||||
Reference in New Issue
Block a user