From 79f645eabcb5be78576a8251d5b5abb322e7ff3a Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 21 Nov 2013 19:17:12 -0600 Subject: [PATCH] Twill-less tool tests - allow tests with GALAXY_TEST_EXTERNAL... ... if GALAXY_TEST_EXTERNAL is ever fixed. --- scripts/functional_tests.py | 2 ++ test/functional/test_toolbox.py | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/functional_tests.py b/scripts/functional_tests.py index 52d7bad0780..c29eec51a2d 100644 --- a/scripts/functional_tests.py +++ b/scripts/functional_tests.py @@ -63,6 +63,7 @@ default_galaxy_test_port_max = 9999 default_galaxy_locales = 'en' default_galaxy_test_file_dir = "test-data" default_galaxy_master_key = "TEST123" +default_galaxy_user_key = None migrated_tool_panel_config = 'migrated_tools_conf.xml' installed_tool_panel_configs = [ 'shed_tool_conf.xml' ] @@ -425,6 +426,7 @@ def main(): functional.test_toolbox.build_tests( testing_shed_tools=testing_shed_tools, master_api_key=master_api_key, + user_api_key=os.environ.get( "GALAXY_TEST_USER_API_KEY", default_galaxy_user_key ), ) test_config = nose.config.Config( env=os.environ, ignoreFiles=ignore_files, plugins=nose.plugins.manager.DefaultPluginManager() ) test_config.configure( sys.argv ) diff --git a/test/functional/test_toolbox.py b/test/functional/test_toolbox.py index 835137d6ca5..385189fcd16 100644 --- a/test/functional/test_toolbox.py +++ b/test/functional/test_toolbox.py @@ -73,7 +73,7 @@ class GalaxyInteractorApi( object ): def __init__( self, twill_test_case ): self.twill_test_case = twill_test_case self.api_url = "%s/api" % twill_test_case.url.rstrip("/") - self.api_key = self.__get_user_key( twill_test_case.master_api_key ) + self.api_key = self.__get_user_key( twill_test_case.user_api_key, twill_test_case.master_api_key ) self.uploads = {} def verify_output( self, history_id, output_data, outfile, attributes, shed_tool_id, maxseconds ): @@ -161,7 +161,9 @@ class GalaxyInteractorApi( object ): ) return self.__post( "tools", files=files, data=data ) - def __get_user_key( self, admin_key ): + def __get_user_key( self, user_key, admin_key ): + if user_key: + return user_key all_users = self.__get( 'users', key=admin_key ).json() try: test_user = [ user for user in all_users if user["email"] == 'test@bx.psu.edu' ][0] @@ -336,7 +338,7 @@ class GalaxyInteractorTwill( object ): return expanded_inputs -def build_tests( testing_shed_tools=False, master_api_key=None ): +def build_tests( testing_shed_tools=False, master_api_key=None, user_api_key=None ): """ If the module level variable `toolbox` is set, generate `ToolTestCase` classes for all of its tests and put them into this modules globals() so @@ -372,6 +374,7 @@ def build_tests( testing_shed_tools=False, master_api_key=None ): namespace[ 'test_tool_%06d' % j ] = test_method namespace[ 'shed_tool_id' ] = shed_tool_id namespace[ 'master_api_key' ] = master_api_key + namespace[ 'user_api_key' ] = user_api_key # The new.classobj function returns a new class object, with name name, derived # from baseclasses (which should be a tuple of classes) and with namespace dict. new_class_obj = new.classobj( name, baseclasses, namespace )