Expose datatype converter information via datatype API.

With test case.
This commit is contained in:
John Chilton
2014-12-25 12:24:23 -05:00
parent 648067c932
commit c70cc95128
3 changed files with 27 additions and 1 deletions
@@ -101,6 +101,19 @@ class DatatypesController( BaseAPIController ):
else:
raise
@expose_api_anonymous
def converters( self, trans, **kwd ):
converters = []
for (source_type, targets) in self._datatypes_registry.datatype_converters.iteritems():
for target_type in targets:
converters.append( {
'source': source_type,
'target': target_type,
'tool_id': targets[ target_type ].id,
} )
return converters
@property
def _datatypes_registry( self ):
return self.app.datatypes_registry
+1 -1
View File
@@ -198,7 +198,7 @@ def populate_api_routes( webapp, app ):
webapp.mapper.resource( 'datatype',
'datatypes',
path_prefix='/api',
collection={ 'sniffers': 'GET', 'mapping' : 'GET' },
collection={ 'sniffers': 'GET', 'mapping' : 'GET', 'converters': 'GET' },
parent_resources=dict( member_name='datatype', collection_name='datatypes' ) )
#webapp.mapper.connect( 'run_workflow', '/api/workflow/{workflow_id}/library/{library_id}', controller='workflows', action='run', workflow_id=None, library_id=None, conditions=dict(method=["GET"]) )
webapp.mapper.resource( 'search', 'search', path_prefix='/api' )
+13
View File
@@ -43,6 +43,19 @@ class DatatypesApiTestCase( api.ApiTestCase ):
xml_index = sniffer_list.index( "galaxy.datatypes.xml:GenericXml" )
assert owl_index < xml_index
def test_converters( self ):
response = self._get( "datatypes/converters" )
self._assert_status_code_is( response, 200 )
converters_list = response.json()
found_fasta_to_tabular = False
for converter in converters_list:
self._assert_has_key( converter, "source", "target", "tool_id" )
if converter["source"] == "fasta" and converter["target"] == "tabular":
found_fasta_to_tabular = True
assert found_fasta_to_tabular
def _index_datatypes( self, data={} ):
response = self._get( "datatypes", data=data )
self._assert_status_code_is( response, 200 )