Allow multiple tool data table config files...

... use this functionality to implement tests for tool data API.
This commit is contained in:
John Chilton
2014-12-15 00:20:35 -05:00
parent 6c344e54bb
commit 33463efe13
5 changed files with 57 additions and 2 deletions
+4 -2
View File
@@ -31,8 +31,10 @@ class ToolDataTableManager( object ):
# at server startup. If tool shed repositories are installed that contain a valid file named tool_data_table_conf.xml.sample, entries
# from that file are inserted into this dict at the time of installation.
self.data_tables = {}
if config_filename:
self.load_from_config_file( config_filename, self.tool_data_path, from_shed_config=False )
for single_config_filename in util.listify( config_filename ):
if not single_config_filename:
continue
self.load_from_config_file( single_config_filename, self.tool_data_path, from_shed_config=False )
def __getitem__( self, key ):
return self.data_tables.__getitem__( key )
+9
View File
@@ -231,7 +231,16 @@ def main():
start_server = 'GALAXY_TEST_EXTERNAL' not in os.environ
tool_data_table_config_path = None
if os.path.exists( 'tool_data_table_conf.test.xml' ):
# If explicitly defined tables for test, use those.
tool_data_table_config_path = 'tool_data_table_conf.test.xml'
else:
# ... otherise find whatever Galaxy would use as the default and
# the sample data for fucntional tests to that.
default_tool_data_config = 'config/tool_data_table_conf.xml.sample'
for tool_data_config in ['config/tool_data_table_conf.xml', 'tool_data_table_conf.xml' ]:
if os.path.exists( tool_data_config ):
default_tool_data_config = tool_data_config
tool_data_table_config_path = '%s,test/functional/tool-data/sample_tool_data_tables.xml' % default_tool_data_config
shed_tool_data_table_config = 'config/shed_tool_data_table_conf.xml'
tool_dependency_dir = os.environ.get( 'GALAXY_TOOL_DEPENDENCY_DIR', None )
use_distributed_object_store = os.environ.get( 'GALAXY_USE_DISTRIBUTED_OBJECT_STORE', False )
+30
View File
@@ -0,0 +1,30 @@
""" Tests for the tool data API.
"""
from base import api
import operator
class ToolDataApiTestCase( api.ApiTestCase ):
def test_admin_only( self ):
index_response = self._get( "tool_data", admin=False )
self._assert_status_code_is( index_response, 403 )
def test_list(self):
index_response = self._get( "tool_data", admin=True )
self._assert_status_code_is( index_response, 200 )
print index_response.content
index = index_response.json()
assert "testalpha" in map(operator.itemgetter("name"), index)
def test_show(self):
show_response = self._get( "tool_data/testalpha", admin=True )
self._assert_status_code_is( show_response, 200 )
print show_response.content
data_table = show_response.json()
assert data_table["columns"] == ["value", "name", "path"]
first_entry = data_table["fields"][0]
assert first_entry[0] == "data1"
assert first_entry[1] == "data1name"
assert first_entry[2].endswith("test/functional/tool-data/data1/entry.txt")
@@ -0,0 +1,12 @@
<tables>
<table name="testalpha" comment_char="#">
<columns>value, name, path</columns>
<file path="${__HERE__}/testalpha.loc" />
</table>
<!--
<table name="testbeta" comment_char="#">
<columns>value, foo, bar, path</columns>
<file path="${__HERE__}/testbeta.loc" />
</table>
-->
</tables>
+2
View File
@@ -0,0 +1,2 @@
data1 data1name ${__HERE__}/data1/entry.txt
data2 data2name ${__HERE__}/data2/entry.txt