mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Extend tool functional test framework to allow testing output dataset metadata.
Adding file test/functional/tools/metadata.xml demonstrating how to check output metadata - this file also demonstrates setting metadata on uploaded datasets and verifies both of these functionalities. Checking output metadata is only available for new API driven tool testing.
This commit is contained in:
@@ -265,10 +265,14 @@ class ToolTestBuilder( object ):
|
||||
attributes['ftype'] = attrib['ftype']
|
||||
for extra in output_elem.findall( 'extra_files' ):
|
||||
extra_files.append( self.__parse_extra_files_elem( extra ) )
|
||||
if not (assert_list or file or extra_files):
|
||||
metadata = {}
|
||||
for metadata_elem in output_elem.findall( 'metadata' ):
|
||||
metadata[ metadata_elem.get('name') ] = metadata_elem.get( 'value' )
|
||||
if not (assert_list or file or extra_files or metadata):
|
||||
raise Exception( "Test output defines not checks (e.g. must have a 'file' check against, assertions to check, etc...)")
|
||||
attributes['assert_list'] = assert_list
|
||||
attributes['extra_files'] = extra_files
|
||||
attributes['metadata'] = metadata
|
||||
self.__add_output( name, file, attributes )
|
||||
except Exception, e:
|
||||
self.error = True
|
||||
|
||||
@@ -88,6 +88,21 @@ class GalaxyInteractorApi( object ):
|
||||
fetcher = self.__dataset_fetcher( history_id )
|
||||
## TODO: Twill version verifys dataset is 'ok' in here.
|
||||
self.twill_test_case.verify_hid( outfile, hda_id=hid, attributes=attributes, dataset_fetcher=fetcher, shed_tool_id=shed_tool_id )
|
||||
metadata = attributes.get( 'metadata', {} )
|
||||
if metadata:
|
||||
dataset = self.__get( "histories/%s/contents/%s" % ( history_id, hid ) ).json()
|
||||
for key, value in metadata.iteritems():
|
||||
dataset_key = "metadata_%s" % key
|
||||
try:
|
||||
dataset_value = dataset.get( dataset_key, None )
|
||||
if dataset_value != value:
|
||||
msg = "Dataset metadata verification for [%s] failed, expected [%s] but found [%s]."
|
||||
msg_params = ( key, value, dataset_value )
|
||||
msg = msg % msg_params
|
||||
raise Exception( msg )
|
||||
except KeyError:
|
||||
msg = "Failed to verify dataset metadata, metadata key [%s] was not found." % key
|
||||
raise Exception( msg )
|
||||
|
||||
def get_job_stream( self, history_id, output_data, stream ):
|
||||
hid = output_data.get( 'id' )
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<tool id="metadata" name="metadata" version="1.0.0">
|
||||
<command>mkdir $output_copy_of_input.extra_files_path; cp $input.extra_files_path/* $output_copy_of_input.extra_files_path; echo "$input.metadata.base_name" > $output_of_input_metadata</command>
|
||||
<inputs>
|
||||
<param name="input" type="data" format="velvet" label="Velvet Dataset" help="Prepared by velveth."/>
|
||||
</inputs>
|
||||
<outputs>
|
||||
<data format="txt" name="output_of_input_metadata" />
|
||||
<data format="velvet" name="output_copy_of_input" />
|
||||
</outputs>
|
||||
<tests>
|
||||
<test>
|
||||
<param name="input" value="velveth_test1/output.html" ftype="velvet" >
|
||||
<composite_data value='velveth_test1/Sequences' ftype="Sequences"/>
|
||||
<composite_data value='velveth_test1/Roadmaps' ftype="Roadmaps"/>
|
||||
<composite_data value='velveth_test1/Log'/>
|
||||
<metadata name="base_name" value="Example Metadata" />
|
||||
</param>
|
||||
<!-- This ouptut tests setting input metadata above -->
|
||||
<output name="output_of_input_metadata">
|
||||
<assert_contents>
|
||||
<has_line line="Example Metadata" />
|
||||
</assert_contents>
|
||||
</output>
|
||||
<!-- This output tests an assertion about output metadata -->
|
||||
<output name="output_copy_of_input" file="velveth_test1/output.html">
|
||||
<metadata name="base_name" value="velvet" />
|
||||
</output>
|
||||
</test>
|
||||
</tests></tool>
|
||||
@@ -9,4 +9,5 @@
|
||||
<tool file="multi_select.xml" />
|
||||
<tool file="multi_output.xml" />
|
||||
<tool file="composite_output.xml" />
|
||||
<tool file="metadata.xml" />
|
||||
</toolbox>
|
||||
Reference in New Issue
Block a user