Fix duplicated names in on_text when using multiple data inputs.

Unit tests verifing the fixed, correct behavior included. Bug introduced in e8c84dd715782e7c1d709d8068e6033b835f7f39 as an unintended consequence of duplicating the first dataset in the dictionary of input datasets generated by the tool action code.

Fixes https://trello.com/c/LCEKxImR.
This commit is contained in:
John Chilton
2014-05-13 17:47:57 -05:00
parent 48ff27d6e3
commit c79e4dcc40
2 changed files with 23 additions and 0 deletions
+9
View File
@@ -472,6 +472,15 @@ class DefaultToolAction( object ):
def on_text_for_names( input_names ):
# input_names may contain duplicates... this is because the first value in
# multiple input dataset parameters will appear twice once as param_name
# and once as param_name1.
unique_names = []
for name in input_names:
if name not in unique_names:
unique_names.append( name )
input_names = unique_names
# Build name for output datasets based on tool name and input names
if len( input_names ) == 1:
on_text = input_names[0]
+14
View File
@@ -2,6 +2,7 @@ import unittest
from galaxy import model
from galaxy.tools.actions import DefaultToolAction
from galaxy.tools.actions import on_text_for_names
import tools_support
@@ -25,6 +26,19 @@ DATA_IN_LABEL_TOOL_CONTENTS = '''<tool id="test_tool" name="Test Tool">
'''
def test_on_text_for_names():
def assert_on_text_is( expected, *names ):
on_text = on_text_for_names( names )
assert on_text == expected, "Wrong on text value %s, expected %s" % ( on_text, expected )
assert_on_text_is( "data 1", "data 1" )
assert_on_text_is( "data 1 and data 2", "data 1", "data 2" )
assert_on_text_is( "data 1, data 2, and data 3", "data 1", "data 2", "data 3" )
assert_on_text_is( "data 1, data 2, and others", "data 1", "data 2", "data 3", "data 4" )
assert_on_text_is( "data 1 and data 2", "data 1", "data 1", "data 2" )
class DefaultToolActionTestCase( unittest.TestCase, tools_support.UsesApp, tools_support.UsesTools ):
def setUp( self ):