Skip to content

Commit

Permalink
Merge pull request #1180 from mvdbeek/download_outputs
Browse files Browse the repository at this point in the history
Allow location to point to url for outputs
  • Loading branch information
jmchilton authored Jul 20, 2021
2 parents e5dd120 + 1f2c7b9 commit 9458533
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 19 additions & 1 deletion planemo/test/_check_output.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""Check an output file from a generalize artifact test."""

import os
import tempfile

import requests
from galaxy.tool_util.parser.interface import TestCollectionOutputDef
from galaxy.tool_util.verify import verify
from galaxy.tool_util.verify.interactor import verify_collection
Expand Down Expand Up @@ -55,7 +57,12 @@ def _verify_output_file(runnable, output_properties, test_properties, **kwds):
if expected_file is None:
expected_file = test_properties.get("path", None)
if expected_file is None:
expected_file = test_properties.get("location", None)
location = test_properties.get("location")
if location:
if location.startswith(('http://', 'https://')):
expected_file = _get_location(location)
else:
expected_file = location.split('file://', 1)[-1]

job_output_files = kwds.get("job_output_files", None)
item_label = "Output with path %s" % path
Expand Down Expand Up @@ -84,6 +91,17 @@ def _check_output_file(runnable, output_properties, test_properties, **kwds):
return problems


def _get_location(location):
data_file = tempfile.NamedTemporaryFile(prefix='planemo_test_file_', delete=False)
with requests.get(location, stream=True) as r:
r.raise_for_status()

for chunk in r.iter_content():
if chunk:
data_file.write(chunk)
return data_file.name


def _test_filename_getter(runnable):

def get_filename(name):
Expand Down
4 changes: 3 additions & 1 deletion tests/data/wf11-remote.gxwf-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
job: wf1.gxwf-job-url.yml
outputs:
wf_output_1:
checksum: "sha1$a0b65939670bc2c010f4d5d6a0b3e4e4590fb92b"
class: File
location: https://raw.githubusercontent.com/galaxyproject/planemo/7be1bf5b3971a43eaa73f483125bfb8cabf1c440/tests/data/hello.txt
compare: contains

0 comments on commit 9458533

Please sign in to comment.