Skip to content

Commit

Permalink
Add test for gx_allow_uri_if_protocol with deferred collections
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Nov 3, 2024
1 parent 53e8a23 commit 2bdcec0
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 11 deletions.
47 changes: 47 additions & 0 deletions lib/galaxy_test/api/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2591,6 +2591,53 @@ def test_allow_uri_if_protocol_on_deferred_input(self, history_id):
output_content = self.dataset_populator.get_history_dataset_content(history_id, dataset=output)
assert output_content.strip() == source_uri.strip()

@skip_without_tool("gx_allow_uri_if_protocol")
def test_allow_uri_if_protocol_on_collection_with_deferred(self, history_id):
source_uris = [
"https://raw.githubusercontent.com/galaxyproject/galaxy/dev/test-data/simple_line.txt",
"https://raw.githubusercontent.com/galaxyproject/galaxy/dev/test-data/simple_line_alternative.txt",
]
elements = [
{
"src": "url",
"url": source_uri,
"deferred": True,
"ext": "txt",
}
for source_uri in source_uris
]
targets = [
{
"destination": {"type": "hdca"},
"elements": elements,
"collection_type": "list",
"name": "deferred list",
}
]
payload = {
"history_id": history_id,
"targets": json.dumps(targets),
}
fetch_response = self.dataset_populator.fetch(payload, wait=True)
dataset_collection = self.dataset_collection_populator.wait_for_fetched_collection(fetch_response)
hdca_id = dataset_collection["id"]
inputs = {
"input1": {"batch": True, "values": [{"src": "hdca", "id": hdca_id}]},
}
run_response = self.dataset_populator.run_tool(
tool_id="gx_allow_uri_if_protocol", inputs=inputs, history_id=history_id
)
hdca_id = run_response["implicit_collections"][0]["id"]
dataset_collection = self.dataset_populator.get_history_collection_details(history_id, id=hdca_id)
elements = dataset_collection["elements"]
assert len(elements) == 2
for element in elements:
object = element["object"]
assert isinstance(object, dict)
assert object["state"] == "ok"
output_content = self.dataset_populator.get_history_dataset_content(history_id, dataset=object)
assert output_content.strip() in source_uris

@skip_without_tool("cat1")
def test_run_deferred_mapping(self, history_id: str):
elements = [
Expand Down
25 changes: 14 additions & 11 deletions test/functional/tools/parameters/gx_allow_uri_if_protocol.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<tool id="gx_allow_uri_if_protocol" name="gx_allow_uri_if_protocol" version="1.0.0">
<command><![CDATA[
## We should handle the case where the input must be treated as a URI with a specific protocol.
#if $input.is_deferred:
## Here, the input is a deferred dataset which source URI has the protocol 'https'.
## The ouput will be the source URI of the input.
echo '$input' > '$output'
#else:
## Here, the input is a regular dataset or a materialized dataset in case of a
## deferred dataset which source URI has a protocol different than 'https'.
## The output will be a copy of the input content.
cp '$input' '$output'
#for $input in $input1:
## We should handle the case where the input must be treated as a URI with a specific protocol.
#if $input.is_deferred:
## Here, the input is a deferred dataset which source URI has the protocol 'https'.
## We append the URI to the output file.
echo '$input' >> '$output'
#else:
## Here, the input is a regular dataset or a materialized dataset in case of a
## deferred dataset which source URI has a protocol different than 'https'.
## We append the content of the dataset to the output file.
cat '$input' >> '$output'
#end if
#end for
]]></command>
<inputs>
<param name="input" type="data" allow_uri_if_protocol="https"/>
<param name="input1" type="data" allow_uri_if_protocol="https" multiple="true"/>
</inputs>
<outputs>
<data name="output" format="txt"/>
Expand Down

0 comments on commit 2bdcec0

Please sign in to comment.