From d9ffbc433ef417c08d5d040b27a6d3d626d54872 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Sat, 31 Dec 2016 10:00:13 -0500 Subject: [PATCH] Test cases for renaming datasets based on tool input datasets. Includes test cases for #3197 and #662. --- test/api/test_workflows.py | 107 +++++++++++++++++- .../tools/for_workflows/mapper2.xml | 33 ++++++ test/functional/tools/samples_tool_conf.xml | 1 + 3 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 test/functional/tools/for_workflows/mapper2.xml diff --git a/test/api/test_workflows.py b/test/api/test_workflows.py index a8d3476c1c6..5d69c9418a7 100644 --- a/test/api/test_workflows.py +++ b/test/api/test_workflows.py @@ -214,7 +214,14 @@ class BaseWorkflowsApiTestCase( api.ApiTestCase, ImporterGalaxyInterface ): input_type = value["type"] if input_type == "File": content = read_test_data(value) - hda = self.dataset_populator.new_dataset( history_id, content=content ) + new_dataset_kwds = { + "content": content + } + if "name" in value: + new_dataset_kwds["name"] = value["name"] + if "file_type" in value: + new_dataset_kwds["file_type"] = value["file_type"] + hda = self.dataset_populator.new_dataset( history_id, **new_dataset_kwds ) label_map[key] = self._ds_entry( hda ) has_uploads = True elif input_type == "raw": @@ -1251,6 +1258,104 @@ test_data: content = self.dataset_populator.get_history_dataset_details( history_id, wait=True, assert_ok=True ) assert content[ "name" ] == "foo was replaced" + @skip_without_tool( "cat" ) + def test_run_rename_based_on_input( self ): + history_id = self.dataset_populator.new_history() + self._run_jobs(""" +class: GalaxyWorkflow +inputs: + - id: input1 +steps: + - tool_id: cat + label: first_cat + state: + input1: + $link: input1 + outputs: + out_file1: + rename: "#{input1 | basename} suffix" +test_data: + input1: + value: 1.fasta + type: File + name: fasta1 +""", history_id=history_id) + content = self.dataset_populator.get_history_dataset_details( history_id, wait=True, assert_ok=True ) + name = content[ "name" ] + assert name == "fasta1 suffix", name + + @skip_without_tool( "cat" ) + def test_run_rename_based_on_input_repeat( self ): + history_id = self.dataset_populator.new_history() + self._run_jobs(""" +class: GalaxyWorkflow +inputs: + - id: input1 + - id: input2 +steps: + - tool_id: cat + label: first_cat + state: + input1: + $link: input1 + queries: + - input2: + $link: input2 + outputs: + out_file1: + rename: "#{queries_0.input2| basename} suffix" +test_data: + input1: + value: 1.fasta + type: File + name: fasta1 + input2: + value: 1.fasta + type: File + name: fasta2 +""", history_id=history_id) + content = self.dataset_populator.get_history_dataset_details( history_id, wait=True, assert_ok=True ) + name = content[ "name" ] + assert name == "fasta2 suffix", name + + @skip_without_tool( "mapper2" ) + def test_run_rename_based_on_input_conditional( self ): + history_id = self.dataset_populator.new_history() + self._run_jobs(""" +class: GalaxyWorkflow +inputs: + - id: fasta_input + - id: fastq_input +steps: + - tool_id: mapper2 + state: + fastq_input: + fastq_input_selector: single + fastq_input1: + $link: fastq_input + reference: + $link: fasta_input + outputs: + out_file1: + # Wish it was qualified for conditionals but it doesn't seem to be. -John + # rename: "#{fastq_input.fastq_input1 | basename} suffix" + rename: "#{fastq_input1 | basename} suffix" +test_data: + fasta_input: + value: 1.fasta + type: File + name: fasta1 + file_type: fasta + fastq_input: + value: 1.fastqsanger + type: File + name: fastq1 + file_type: fastqsanger +""", history_id=history_id) + content = self.dataset_populator.get_history_dataset_details( history_id, wait=True, assert_ok=True ) + name = content[ "name" ] + assert name == "fastq1 suffix", name + @skip_without_tool( "cat1" ) def test_run_with_runtime_pja( self ): workflow = self.workflow_populator.load_workflow( name="test_for_pja_runtime" ) diff --git a/test/functional/tools/for_workflows/mapper2.xml b/test/functional/tools/for_workflows/mapper2.xml new file mode 100644 index 00000000000..3b355c6628c --- /dev/null +++ b/test/functional/tools/for_workflows/mapper2.xml @@ -0,0 +1,33 @@ + + + cp $__tool_directory__/1.bam $out_file1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/functional/tools/samples_tool_conf.xml b/test/functional/tools/samples_tool_conf.xml index ccef907c6a1..58ecb3b6f5a 100644 --- a/test/functional/tools/samples_tool_conf.xml +++ b/test/functional/tools/samples_tool_conf.xml @@ -114,6 +114,7 @@ +