mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Python3: open 2 files in binary mode
Fix `HistoriesApiTestCase.test_import_metadata_regeneration()` API test
introduced in commit 38f7aded0b .
See:
https://jenkins.galaxyproject.org/job/docker-api-py3/193/testReport/junit/test.api.test_histories/HistoriesApiTestCase/test_import_metadata_regeneration/
This commit is contained in:
@@ -351,23 +351,23 @@ class DatasetsController(BaseAPIController, UsesVisualizationMixin):
|
||||
else:
|
||||
file_path = hda.file_name
|
||||
rval = open(file_path, 'rb')
|
||||
|
||||
else:
|
||||
display_kwd = kwd.copy()
|
||||
if 'key' in display_kwd:
|
||||
del display_kwd["key"]
|
||||
rval = hda.datatype.display_data(trans, hda, preview, filename, to_ext, **display_kwd)
|
||||
|
||||
except Exception as exception:
|
||||
log.error("Error getting display data for dataset (%s) from history (%s): %s",
|
||||
history_content_id, history_id, str(exception), exc_info=True)
|
||||
except Exception as e:
|
||||
log.exception("Error getting display data for dataset (%s) from history (%s)",
|
||||
history_content_id, history_id)
|
||||
trans.response.status = 500
|
||||
rval = ("Could not get display data for dataset: " + str(exception))
|
||||
|
||||
rval = "Could not get display data for dataset: %s" % e
|
||||
return rval
|
||||
|
||||
@web.expose_api_raw_anonymous
|
||||
def get_metadata_file(self, trans, history_content_id, history_id, metadata_file=None, **kwd):
|
||||
"""
|
||||
GET /api/histories/{history_id}/contents/{history_content_id}/metadata_file
|
||||
"""
|
||||
decoded_content_id = self.decode_id(history_content_id)
|
||||
rval = ''
|
||||
try:
|
||||
@@ -376,12 +376,12 @@ class DatasetsController(BaseAPIController, UsesVisualizationMixin):
|
||||
fname = ''.join(c in util.FILENAME_VALID_CHARS and c or '_' for c in hda.name)[0:150]
|
||||
trans.response.headers["Content-Type"] = "application/octet-stream"
|
||||
trans.response.headers["Content-Disposition"] = 'attachment; filename="Galaxy%s-[%s].%s"' % (hda.hid, fname, file_ext)
|
||||
return open(hda.metadata.get(metadata_file).file_name)
|
||||
except Exception as exception:
|
||||
log.error("Error getting metadata_file (%s) for dataset (%s) from history (%s): %s",
|
||||
metadata_file, history_content_id, history_id, str(exception), exc_info=True)
|
||||
return open(hda.metadata.get(metadata_file).file_name, 'rb')
|
||||
except Exception as e:
|
||||
log.exception("Error getting metadata_file (%s) for dataset (%s) from history (%s)",
|
||||
metadata_file, history_content_id, history_id)
|
||||
trans.response.status = 500
|
||||
rval = ("Could not get display data for dataset: " + str(exception))
|
||||
rval = "Could not get metadata for dataset: %s" % e
|
||||
return rval
|
||||
|
||||
@web._future_expose_api_anonymous
|
||||
|
||||
@@ -192,7 +192,7 @@ class HistoriesApiTestCase(api.ApiTestCase):
|
||||
def test_import_metadata_regeneration(self):
|
||||
history_name = "for_import_metadata_regeneration"
|
||||
history_id = self.dataset_populator.new_history(name=history_name)
|
||||
self.dataset_populator.new_dataset(history_id, content=open(self.test_data_resolver.get_filename("1.bam")), file_type='bam')
|
||||
self.dataset_populator.new_dataset(history_id, content=open(self.test_data_resolver.get_filename("1.bam"), 'rb'), file_type='bam')
|
||||
imported_history_id = self._reimport_history(history_id, history_name)
|
||||
self._assert_history_length(imported_history_id, 1)
|
||||
import_bam_metadata = self.dataset_populator.get_history_dataset_details(
|
||||
@@ -203,7 +203,7 @@ class HistoriesApiTestCase(api.ApiTestCase):
|
||||
assert bai_metadata["file_type"] == "bam_index"
|
||||
api_url = bai_metadata["download_url"].split("api/", 1)[1]
|
||||
bai_response = self._get(api_url)
|
||||
assert bai_response.status_code == 200
|
||||
self._assert_status_code_is(bai_response, 200)
|
||||
assert len(bai_response.content) > 4
|
||||
|
||||
def test_import_export_collection(self):
|
||||
|
||||
Reference in New Issue
Block a user