Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow location to point to url for outputs #1180

Merged
merged 2 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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