Skip to content

Commit

Permalink
Allow testing element counts in tool output collections.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Mar 17, 2016
1 parent 29b6d54 commit 13f05d2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/galaxy/tools/parser/interface.py
Expand Up @@ -347,10 +347,11 @@ def collect_inputs( self ):


class TestCollectionOutputDef( object ):
# TODO: do not require XML directly here.

def __init__( self, name, attrib, element_tests ):
self.name = name
self.collection_type = attrib.get( "type", None )
count = attrib.get("count", None)
self.count = int(count) if count is not None else None
self.attrib = attrib
self.element_tests = element_tests
8 changes: 8 additions & 0 deletions test/functional/test_toolbox.py
Expand Up @@ -213,6 +213,14 @@ def get_element( elements, id ):
message = template % (name, expected_collection_type, collection_type)
raise AssertionError(message)

expected_element_count = output_collection_def.count
if expected_element_count:
actual_element_count = len(data_collection[ "elements" ])
if expected_element_count != actual_element_count:
template = "Expected output collection [%s] to have %s elements, but it had %s."
message = template % (name, expected_element_count, actual_element_count)
raise AssertionError(message)

def verify_elements( element_objects, element_tests ):
for element_identifier, ( element_outfile, element_attrib ) in element_tests.items():
element = get_element( element_objects, element_identifier )
Expand Down
2 changes: 1 addition & 1 deletion test/functional/tools/collection_creates_list.xml
Expand Up @@ -22,7 +22,7 @@
<element name="l12" value="simple_line.txt" />
</collection>
</param>
<output_collection name="list_output" type="list">
<output_collection name="list_output" type="list" count="2">
<element name="l11">
<assert_contents>
<has_text_matching expression="^identifier is l11\n$" />
Expand Down

0 comments on commit 13f05d2

Please sign in to comment.