Skip to content

Commit

Permalink
More tests for various data column feature combos.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Sep 17, 2024
1 parent 5acc518 commit 1410dda
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 0 deletions.
35 changes: 35 additions & 0 deletions lib/galaxy_test/api/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,41 @@ def test_optional_repeats_with_mins_filled_id(self):
assert "false" in output1_content
assert "length: 2" in output1_content

def test_data_column_defaults(self):
with self.dataset_populator.test_history(require_new=False) as history_id:
hda = dataset_to_param(self.dataset_populator.new_dataset(history_id, content="1\t2\t3\t4", file_type="tabular"))
inputs = {"ref_parameter": hda}
response = self._run("gx_data_column", history_id, inputs, assert_ok=False).json()
output = response["outputs"]
details = self.dataset_populator.get_history_dataset_details(history_id, dataset=output[0], assert_ok=False)
assert details["state"] == "error"

with self.dataset_populator.test_history(require_new=True) as history_id:
response = self._run("gx_data_column_optional", history_id, inputs, assert_ok=True)
output = response["outputs"]
content = self.dataset_populator.get_history_dataset_content(history_id, dataset=output[0])
assert "parameter: None" in content

response = self._run("gx_data_column_with_default", history_id, inputs, assert_ok=True)
output = response["outputs"]
content = self.dataset_populator.get_history_dataset_content(history_id, dataset=output[0])
assert "parameter: 2" in content

response = self._run("gx_data_column_with_default_legacy", history_id, inputs, assert_ok=True)
output = response["outputs"]
content = self.dataset_populator.get_history_dataset_content(history_id, dataset=output[0])
assert "parameter: 3" in content

response = self._run("gx_data_column_accept_default", history_id, inputs, assert_ok=True)
output = response["outputs"]
content = self.dataset_populator.get_history_dataset_content(history_id, dataset=output[0])
assert "parameter: 1" in content

response = self._run("gx_data_column_multiple_with_default", history_id, inputs, assert_ok=True)
output = response["outputs"]
content = self.dataset_populator.get_history_dataset_content(history_id, dataset=output[0])
assert "parameter: 1,2" in content

@skip_without_tool("library_data")
def test_library_data_param(self):
with self.dataset_populator.test_history(require_new=False) as history_id:
Expand Down
21 changes: 21 additions & 0 deletions test/functional/tools/parameters/gx_data_column_accept_default.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<tool id="gx_data_column_accept_default" name="gx_data_column_accept_default" version="1.0.0">
<macros>
<import>macros.xml</import>
</macros>
<command><![CDATA[
echo 'parameter: $parameter' >> '$output'
]]></command>
<inputs>
<param name="ref_parameter" type="data" format="tabular" />
<param name="parameter" type="data_column" data_ref="ref_parameter" accept_default="true" />
</inputs>
<expand macro="simple_text_output" />
<tests>
<test>
<param name="ref_parameter" value="2.tabular" />
<expand macro="assert_output">
<has_line line="parameter: None"/>
</expand>
</test>
</tests>
</tool>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<tool id="gx_data_column_multiple_with_default" name="gx_data_column_multiple_with_default" version="1.0.0">
<macros>
<import>macros.xml</import>
</macros>
<command><![CDATA[
echo "parameter: $parameter" >> '$output'
]]></command>
<inputs>
<param name="ref_parameter" type="data" format="tabular" />
<param name="parameter" type="data_column" data_ref="ref_parameter" multiple="true" value="1,2" />
</inputs>
<expand macro="simple_text_output" />
<tests>
<test>
<param name="ref_parameter" value="2.tabular" />
<expand macro="assert_output">
<has_line line="parameter: 1,2"/>
</expand>
</test>
</tests>
</tool>
22 changes: 22 additions & 0 deletions test/functional/tools/parameters/gx_data_column_with_default.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<tool id="gx_data_column_with_default" name="gx_data_column_with_default" version="1.0.0">
<macros>
<import>macros.xml</import>
</macros>
<command><![CDATA[
echo 'parameter: $parameter' >> '$output'
]]></command>
<inputs>
<param name="ref_parameter" type="data" format="tabular" />
<param name="parameter" type="data_column" data_ref="ref_parameter" value="2" />
</inputs>
<expand macro="simple_text_output" />
<tests>
<!-- these parameters are implicitly optional -->
<test>
<param name="ref_parameter" value="2.tabular" />
<expand macro="assert_output">
<has_line line="parameter: 2"/>
</expand>
</test>
</tests>
</tool>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<tool id="gx_data_column_with_default_legacy" name="gx_data_column_with_default_legacy" version="1.0.0">
<macros>
<import>macros.xml</import>
</macros>
<command><![CDATA[
echo 'parameter: $parameter' >> '$output'
]]></command>
<inputs>
<param name="ref_parameter" type="data" format="tabular" />
<param name="parameter" type="data_column" data_ref="ref_parameter" default_value="3" />
</inputs>
<expand macro="simple_text_output" />
<tests>
<!-- these parameters are implicitly optional -->
<test>
<param name="ref_parameter" value="2.tabular" />
<expand macro="assert_output">
<has_line line="parameter: 3"/>
</expand>
</test>
</tests>
</tool>

0 comments on commit 1410dda

Please sign in to comment.