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 ff5e040
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 3 deletions.
42 changes: 42 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,48 @@ 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=False) as history_id:
response = self._run("gx_data_column_multiple", history_id, inputs, assert_ok=False).json()
assert "err_msg" in response, str(response)
assert "parameter 'parameter': an invalid option" in response["err_msg"]

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: 1"/>
</expand>
</test>
</tests>
</tool>
3 changes: 0 additions & 3 deletions test/functional/tools/parameters/gx_data_column_multiple.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ echo 'parameter: $parameter' >> '$output'
<!-- these parameters are not implicitly optional! -->
<test expect_failure="true">
<param name="ref_parameter" value="2.tabular" />
<expand macro="assert_output">
<has_line line="parameter: 1"/>
</expand>
</test>
</tests>
</tool>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<tool id="gx_data_column_multiple_accept_default" name="gx_data_column_multiple_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" multiple="true" 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: 1"/>
</expand>
</test>
</tests>
</tool>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<tool id="gx_data_column_multiple_optional_with_default" name="gx_data_column_multiple_optional_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" optional="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>
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 ff5e040

Please sign in to comment.