1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/c510097f7018/ changeset: c510097f7018 user: greg date: 2012-03-29 18:03:14 summary: Enhance the functional test framework to support tools migrated from the distribution and installed from the tool shed. To test these tools, use: sh run_functional_tests.sh --migrated affected #: 6 files diff -r 7ab3012fe281f9219e2323e6c8c9694fc2b2628a -r c510097f7018dbc177513a62c0ca46b4cace0c86 lib/galaxy/tool_shed/install_manager.py --- a/lib/galaxy/tool_shed/install_manager.py +++ b/lib/galaxy/tool_shed/install_manager.py @@ -276,7 +276,6 @@ root = tree.getroot() tool_path = root.get( 'tool_path', None ) if tool_path is None: - # There will be a problem here if the user has defined 2 non-shed related configs. config_filenames.append( config_filename ) return config_filenames def __get_url_from_tool_shed( self, tool_shed ): diff -r 7ab3012fe281f9219e2323e6c8c9694fc2b2628a -r c510097f7018dbc177513a62c0ca46b4cace0c86 lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -124,7 +124,7 @@ elif elem.tag == 'section': self.load_section_tag_set( elem, tool_path, load_panel_dict ) elif elem.tag == 'label': - self.load_label_tag_set( elem, self.tool_panel, self.integrated_tool_panel ) + self.load_label_tag_set( elem, self.tool_panel, self.integrated_tool_panel, load_panel_dict ) if parsing_shed_tool_conf: shed_tool_conf_dict = dict( config_filename=config_filename, tool_path=tool_path, @@ -370,10 +370,10 @@ integrated_panel_dict[ key ] = workflow except: log.exception( "Error loading workflow: %s" % workflow_id ) - def load_label_tag_set( self, elem, panel_dict, integrated_panel_dict ): + def load_label_tag_set( self, elem, panel_dict, integrated_panel_dict, load_panel_dict ): label = ToolSectionLabel( elem ) key = 'label_' + label.id - if not self.integrated_tool_panel_config_has_contents: + if load_panel_dict: panel_dict[ key ] = label integrated_panel_dict[ key ] = label def load_section_tag_set( self, elem, tool_path, load_panel_dict ): @@ -396,7 +396,7 @@ elif sub_elem.tag == 'workflow': self.load_workflow_tag_set( sub_elem, elems, integrated_elems, load_panel_dict ) elif sub_elem.tag == 'label': - self.load_label_tag_set( sub_elem, elems, integrated_elems ) + self.load_label_tag_set( sub_elem, elems, integrated_elems, load_panel_dict ) if load_panel_dict: self.tool_panel[ key ] = section # Always load sections into the integrated_tool_panel. diff -r 7ab3012fe281f9219e2323e6c8c9694fc2b2628a -r c510097f7018dbc177513a62c0ca46b4cace0c86 run_functional_tests.sh --- a/run_functional_tests.sh +++ b/run_functional_tests.sh @@ -20,6 +20,15 @@ echo "===========================================================================================================================================" echo "'run_functional_tests.sh -id bbb' for testing one tool with id 'bbb' ('bbb' is the tool id)" echo "'run_functional_tests.sh -sid ccc' for testing one section with sid 'ccc' ('ccc' is the string after 'section::')" +elif [ $1 = '--migrated' ]; then + if [ ! $2 ]; then + python ./scripts/functional_tests.py -v functional.test_toolbox --with-nosehtml --html-report-file run_functional_tests.html --migrated + elif [ $2 = '-id' ]; then + # TODO: This option is not tested... + python ./scripts/functional_tests.py -v functional.test_toolbox:TestForTool_$3 --with-nosehtml --html-report-file run_functional_tests.html --migrated + else + python ./scripts/functional_tests.py -v functional.test_toolbox --with-nosehtml --html-report-file run_functional_tests.html --migrated + fi else python ./scripts/functional_tests.py -v --with-nosehtml --html-report-file run_functional_tests.html $1 fi diff -r 7ab3012fe281f9219e2323e6c8c9694fc2b2628a -r c510097f7018dbc177513a62c0ca46b4cace0c86 scripts/functional_tests.py --- a/scripts/functional_tests.py +++ b/scripts/functional_tests.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -import os, sys, shutil +import os, sys, shutil, tempfile, re # Assume we are run from the galaxy root directory, add lib to the python path cwd = os.getcwd() @@ -32,6 +32,13 @@ from galaxy.web import buildapp from galaxy import tools from galaxy.util import bunch +from galaxy import util +from galaxy.util.json import to_json_string + +import nose.core +import nose.config +import nose.loader +import nose.plugins.manager log = logging.getLogger( "functional_tests.py" ) @@ -40,28 +47,87 @@ default_galaxy_test_port_max = 9999 default_galaxy_locales = 'en' default_galaxy_test_file_dir = "test-data" +migrated_tool_panel_config = 'migrated_tools_conf.xml' -def main(): - +def get_installed_repository_info( elem, last_galaxy_test_file_dir, last_tested_repository_name, last_tested_changeset_revision ): + """ + Return the GALAXY_TEST_FILE_DIR, the containing repository name and the change set revision for the tool elem. + This only happens when testing tools eliminated from the distribution and now installed from the tool shed. + """ + tool_config_path = elem.get( 'file' ) + installed_tool_path_items = tool_config_path.split( '/repos/' ) + sans_shed = installed_tool_path_items[ 1 ] + path_items = sans_shed.split( '/' ) + repository_name = path_items[ 1 ] + changeset_revision = path_items[ 2 ] + if repository_name != last_tested_repository_name or changeset_revision != last_tested_changeset_revision: + # Locate the test-data directory. + installed_tool_path = os.path.join( installed_tool_path_items[ 0 ], 'repos', 'devteam', repository_name, changeset_revision ) + for root, dirs, files in os.walk( installed_tool_path ): + if 'test-data' in dirs: + return os.path.join( root, 'test-data' ), repository_name, changeset_revision + return None, repository_name, changeset_revision + return last_galaxy_test_file_dir, last_tested_repository_name, last_tested_changeset_revision + +def run_tests( test_config ): + loader = nose.loader.TestLoader( config=test_config ) + plug_loader = test_config.plugins.prepareTestLoader( loader ) + if plug_loader is not None: + loader = plug_loader + tests = loader.loadTestsFromNames( test_config.testNames ) + test_runner = nose.core.TextTestRunner( stream=test_config.stream, + verbosity=test_config.verbosity, + config=test_config ) + plug_runner = test_config.plugins.prepareTestRunner( test_runner ) + if plug_runner is not None: + test_runner = plug_runner + return test_runner.run( tests ) + +def main(): # ---- Configuration ------------------------------------------------------ - galaxy_test_host = os.environ.get( 'GALAXY_TEST_HOST', default_galaxy_test_host ) galaxy_test_port = os.environ.get( 'GALAXY_TEST_PORT', None ) galaxy_test_save = os.environ.get( 'GALAXY_TEST_SAVE', None) + tool_path = os.environ.get( 'GALAXY_TEST_TOOL_PATH', 'tools' ) + if 'HTTP_ACCEPT_LANGUAGE' not in os.environ: + os.environ[ 'HTTP_ACCEPT_LANGUAGE' ] = default_galaxy_locales + testing_migrated_tools = '--migrated' in sys.argv - if 'HTTP_ACCEPT_LANGUAGE' not in os.environ: - os.environ['HTTP_ACCEPT_LANGUAGE'] = default_galaxy_locales - galaxy_test_file_dir = os.environ.get( 'GALAXY_TEST_FILE_DIR', default_galaxy_test_file_dir ) - if not os.path.isabs( galaxy_test_file_dir ): - galaxy_test_file_dir = os.path.join( os.getcwd(), galaxy_test_file_dir ) - start_server = 'GALAXY_TEST_EXTERNAL' not in os.environ - tool_path = os.environ.get( 'GALAXY_TEST_TOOL_PATH', 'tools' ) - tool_config_file = os.environ.get( 'GALAXY_TEST_TOOL_CONF', 'tool_conf.xml.sample' ) - tool_data_table_config_path = 'tool_data_table_conf.xml' + if testing_migrated_tools: + sys.argv.pop() + # Store a jsonified dictionary of tool_id : GALAXY_TEST_FILE_DIR pairs. + galaxy_migrated_tools_file = 'migrated_tools_dict' + migrated_tools_dict = {} + # We need the upload tool for functional tests, so we'll create a temporary tool panel config that defines it. + fd, tmp_tool_panel_conf = tempfile.mkstemp() + os.write( fd, '<?xml version="1.0"?>\n' ) + os.write( fd, '<toolbox>\n' ) + os.write( fd, '<tool file="data_source/upload.xml"/>\n' ) + os.write( fd, '</toolbox>\n' ) + os.close( fd ) + tool_config_file = tmp_tool_panel_conf + galaxy_test_file_dir = None + library_import_dir = None + user_library_import_dir = None + # Exclude all files except test_toolbox.py. + ignore_files = ( re.compile( r'^test_[adghlmsu]*' ), re.compile( r'^test_ta*' ) ) + else: + tool_config_file = os.environ.get( 'GALAXY_TEST_TOOL_CONF', 'tool_conf.xml.sample' ) + galaxy_test_file_dir = os.environ.get( 'GALAXY_TEST_FILE_DIR', default_galaxy_test_file_dir ) + if not os.path.isabs( galaxy_test_file_dir ): + galaxy_test_file_dir = os.path.join( os.getcwd(), galaxy_test_file_dir ) + library_import_dir = galaxy_test_file_dir + user_library_import_dir = os.path.join( galaxy_test_file_dir, 'users' ) + ignore_files = () + + start_server = 'GALAXY_TEST_EXTERNAL' not in os.environ + if os.path.exists( 'tool_data_table_conf.test.xml' ): + tool_data_table_config_path = 'tool_data_table_conf.test.xml' + else: + tool_data_table_config_path = '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 ) - if os.path.exists( 'tool_data_table_conf.test.xml' ): - tool_data_table_config_path = 'tool_data_table_conf.test.xml' + if start_server: psu_production = False galaxy_test_proxy_port = None @@ -126,38 +192,21 @@ try: os.makedirs( dir ) except OSError: - pass - + pass print "Database connection:", database_connection - - # What requires these? - # handy for (eg) functional tests to save outputs? - if galaxy_test_save: - os.environ['GALAXY_TEST_SAVE'] = galaxy_test_save - # pass in through script setenv - # will leave a copy of ALL test validate files - os.environ['GALAXY_TEST_HOST'] = galaxy_test_host - os.environ['GALAXY_TEST_FILE_DIR'] = galaxy_test_file_dir - # ---- Build Application -------------------------------------------------- - - app = None - + # ---- Build Application -------------------------------------------------- + app = None if start_server: - global_conf = { '__file__' : 'universe_wsgi.ini.sample' } if psu_production: global_conf = None - if not database_connection.startswith( 'sqlite://' ): - kwargs['database_engine_option_max_overflow'] = '20' - + kwargs[ 'database_engine_option_max_overflow' ] = '20' if tool_dependency_dir is not None: - kwargs['tool_dependency_dir'] = tool_dependency_dir - + kwargs[ 'tool_dependency_dir' ] = tool_dependency_dir if use_distributed_object_store: - kwargs['object_store'] = 'distributed' - kwargs['distributed_object_store_config_file'] = 'distributed_object_store_conf.xml.sample' - + kwargs[ 'object_store' ] = 'distributed' + kwargs[ 'distributed_object_store_config_file' ] = 'distributed_object_store_conf.xml.sample' # Build the Universe Application app = UniverseApplication( job_queue_workers = 5, id_secret = 'changethisinproductiontoo', @@ -179,21 +228,16 @@ allow_user_deletion = True, admin_users = 'test@bx.psu.edu', allow_library_path_paste = True, - library_import_dir = galaxy_test_file_dir, - user_library_import_dir = os.path.join( galaxy_test_file_dir, 'users' ), + library_import_dir = library_import_dir, + user_library_import_dir = user_library_import_dir, global_conf = global_conf, **kwargs ) - - log.info( "Embedded Universe application started" ); - + log.info( "Embedded Universe application started" ) # ---- Run webserver ------------------------------------------------------ - server = None if start_server: - - webapp = buildapp.app_factory( dict(), use_translogger = False, static_enabled = False, app=app ) - + webapp = buildapp.app_factory( dict(), use_translogger=False, static_enabled=False, app=app ) if galaxy_test_port is not None: server = httpserver.serve( webapp, host=galaxy_test_host, port=galaxy_test_port, start_loop=False ) else: @@ -217,7 +261,6 @@ t = threading.Thread( target=server.serve_forever ) t.start() - # Test if the server is up for i in range( 10 ): conn = httplib.HTTPConnection( galaxy_test_host, galaxy_test_port ) # directly test the app, not the proxy @@ -227,85 +270,105 @@ time.sleep( 0.1 ) else: raise Exception( "Test HTTP server did not return '200 OK' after 10 tries" ) - # Test if the proxy server is up if psu_production: conn = httplib.HTTPConnection( galaxy_test_host, galaxy_test_proxy_port ) # directly test the app, not the proxy conn.request( "GET", "/" ) if not conn.getresponse().status == 200: raise Exception( "Test HTTP proxy server did not return '200 OK'" ) - log.info( "Embedded web server started" ) - - # ---- Load toolbox for generated tests ----------------------------------- - # We don't add the tests to the path until everything is up and running new_path = [ os.path.join( cwd, "test" ) ] new_path.extend( sys.path[1:] ) sys.path = new_path - import functional.test_toolbox - - if app: - # TODO: provisions for loading toolbox from file when using external server - functional.test_toolbox.toolbox = app.toolbox - functional.test_toolbox.build_tests() - else: - # FIXME: This doesn't work at all now that toolbox requires an 'app' instance - # (to get at datatypes, might just pass a datatype registry directly) - datatypes_registry = galaxy.datatypes.registry.Registry() - datatypes_registry.load_datatypes() - my_app = bunch.Bunch( datatypes_registry ) - test_toolbox.toolbox = tools.ToolBox( 'tool_conf.xml.test', 'tools', my_app ) - # ---- Find tests --------------------------------------------------------- - if galaxy_test_proxy_port: log.info( "Functional tests will be run against %s:%s" % ( galaxy_test_host, galaxy_test_proxy_port ) ) else: log.info( "Functional tests will be run against %s:%s" % ( galaxy_test_host, galaxy_test_port ) ) - success = False - try: - - import nose.core - import nose.config - import nose.loader - import nose.plugins.manager - - test_config = nose.config.Config( env = os.environ, plugins=nose.plugins.manager.DefaultPluginManager() ) - test_config.configure( sys.argv ) - - loader = nose.loader.TestLoader( config = test_config ) - - plug_loader = test_config.plugins.prepareTestLoader( loader ) - if plug_loader is not None: - loader = plug_loader - - tests = loader.loadTestsFromNames( test_config.testNames ) - - test_runner = nose.core.TextTestRunner( - stream = test_config.stream, - verbosity = test_config.verbosity, - config = test_config) - - plug_runner = test_config.plugins.prepareTestRunner( test_runner ) - if plug_runner is not None: - test_runner = plug_runner - - result = test_runner.run( tests ) - - success = result.wasSuccessful() - + # What requires these? Handy for (eg) functional tests to save outputs? + if galaxy_test_save: + os.environ[ 'GALAXY_TEST_SAVE' ] = galaxy_test_save + # Pass in through script setenv, will leave a copy of ALL test validate files + os.environ[ 'GALAXY_TEST_HOST' ] = galaxy_test_host + if testing_migrated_tools: + last_galaxy_test_file_dir = None + last_tested_repository_name = None + last_tested_changeset_revision = None + tree = util.parse_xml( migrated_tool_panel_config ) + root = tree.getroot() + migrated_tool_path = root.get( 'tool_path' ) + counter = 0 + for elem in root: + if elem.tag == 'tool': + galaxy_test_file_dir, \ + last_tested_repository_name, \ + last_tested_changeset_revision = get_installed_repository_info( elem, + last_galaxy_test_file_dir, + last_tested_repository_name, + last_tested_changeset_revision ) + if galaxy_test_file_dir: + if galaxy_test_file_dir != last_galaxy_test_file_dir: + if not os.path.isabs( galaxy_test_file_dir ): + galaxy_test_file_dir = os.path.join( os.getcwd(), galaxy_test_file_dir ) + guid = elem.get( 'guid' ) + migrated_tools_dict[ guid ] = galaxy_test_file_dir + last_galaxy_test_file_dir = galaxy_test_file_dir + elif elem.tag == 'section': + for section_elem in elem: + if section_elem.tag == 'tool': + galaxy_test_file_dir, \ + last_tested_repository_name, \ + last_tested_changeset_revision = get_installed_repository_info( section_elem, + last_galaxy_test_file_dir, + last_tested_repository_name, + last_tested_changeset_revision ) + if galaxy_test_file_dir: + if galaxy_test_file_dir != last_galaxy_test_file_dir: + if not os.path.isabs( galaxy_test_file_dir ): + galaxy_test_file_dir = os.path.join( os.getcwd(), galaxy_test_file_dir ) + guid = section_elem.get( 'guid' ) + migrated_tools_dict[ guid ] = galaxy_test_file_dir + last_galaxy_test_file_dir = galaxy_test_file_dir + # Persist the migrated_tools_dict to the galaxy_migrated_tools_file. + migrated_tools_file = open( galaxy_migrated_tools_file, 'w' ) + migrated_tools_file.write( to_json_string( migrated_tools_dict ) ) + migrated_tools_file.close() + if not os.path.isabs( galaxy_migrated_tools_file ): + galaxy_migrated_tools_file = os.path.join( os.getcwd(), galaxy_migrated_tools_file ) + os.environ[ 'GALAXY_MIGRATED_TOOLS_FILE' ] = galaxy_migrated_tools_file + functional.test_toolbox.toolbox = app.toolbox + functional.test_toolbox.build_tests( testing_migrated_tools=True ) + test_config = nose.config.Config( env=os.environ, ignoreFiles=ignore_files, plugins=nose.plugins.manager.DefaultPluginManager() ) + test_config.configure( sys.argv ) + result = run_tests( test_config ) + success = result.wasSuccessful() + try: + os.unlink( tmp_tool_panel_conf ) + except: + log.info( "Unable to remove temporary file: %s" % tmp_tool_panel_conf ) + try: + os.unlink( galaxy_migrated_tools_file ) + except: + log.info( "Unable to remove file: %s" % galaxy_migrated_tools_file ) + else: + functional.test_toolbox.toolbox = app.toolbox + functional.test_toolbox.build_tests() + if galaxy_test_file_dir: + os.environ[ 'GALAXY_TEST_FILE_DIR' ] = galaxy_test_file_dir + test_config = nose.config.Config( env=os.environ, ignoreFiles=ignore_files, plugins=nose.plugins.manager.DefaultPluginManager() ) + test_config.configure( sys.argv ) + result = run_tests( test_config ) + success = result.wasSuccessful() except: log.exception( "Failure running tests" ) log.info( "Shutting down" ) - - # ---- Teardown ----------------------------------------------------------- - + # ---- Tear down ----------------------------------------------------------- if server: log.info( "Shutting down embedded web server" ) server.server_close() @@ -330,7 +393,6 @@ shutil.rmtree( dir ) except: pass - if success: return 0 else: diff -r 7ab3012fe281f9219e2323e6c8c9694fc2b2628a -r c510097f7018dbc177513a62c0ca46b4cace0c86 test/base/twilltestcase.py --- a/test/base/twilltestcase.py +++ b/test/base/twilltestcase.py @@ -39,8 +39,9 @@ self.migrated_tools_file = os.environ.get( 'GALAXY_MIGRATED_TOOLS_FILE', None ) if self.migrated_tools_file: f = open( self.migrated_tools_file, 'r' ) - self.migrated_tools_dict = from_json_string( f.readlines() ) + text = f.read() f.close() + self.migrated_tools_dict = from_json_string( text ) else: self.migrated_tools_dict = {} self.keepOutdir = os.environ.get( 'GALAXY_TEST_SAVE', '' ) @@ -51,8 +52,6 @@ pass self.home() - #self.set_history() - # Functions associated with files def files_diff( self, file1, file2, attributes=None ): """Checks the contents of 2 files for differences""" @@ -170,17 +169,25 @@ if line_diff_count > lines_diff: raise AssertionError, "Failed to find '%s' in history data. (lines_diff=%i):\n" % ( contains, lines_diff ) - def get_filename( self, filename ): - full = os.path.join( self.file_dir, filename) - return os.path.abspath(full) + def get_filename( self, filename, migrated_tool_id=None ): + if migrated_tool_id and self.migrated_tools_dict: + file_dir = self.migrated_tools_dict[ migrated_tool_id ] + if not file_dir: + file_dir = self.file_dir + else: + file_dir = self.file_dir + return os.path.abspath( os.path.join( file_dir, filename ) ) def save_log( *path ): """Saves the log to a file""" filename = os.path.join( *path ) file(filename, 'wt').write(buffer.getvalue()) - def upload_file( self, filename, ftype='auto', dbkey='unspecified (?)', space_to_tab = False, metadata = None, composite_data = None ): - """Uploads a file""" + def upload_file( self, filename, ftype='auto', dbkey='unspecified (?)', space_to_tab=False, metadata=None, composite_data=None, migrated_tool_id=None ): + """ + Uploads a file. If migrated_tool_id has a value, we're testing tools migrated from the distribution to the tool shed, + so the tool-data directory of test data files is contained in the installed tool shed repository. + """ self.visit_url( "%s/tool_runner?tool_id=upload1" % self.url ) try: self.refresh_form( "file_type", ftype ) #Refresh, to support composite files @@ -190,11 +197,11 @@ tc.fv( "1", "files_metadata|%s" % elem.get( 'name' ), elem.get( 'value' ) ) if composite_data: for i, composite_file in enumerate( composite_data ): - filename = self.get_filename( composite_file.get( 'value' ) ) + filename = self.get_filename( composite_file.get( 'value' ), migrated_tool_id=migrated_tool_id ) tc.formfile( "1", "files_%i|file_data" % i, filename ) tc.fv( "1", "files_%i|space_to_tab" % i, composite_file.get( 'space_to_tab', False ) ) else: - filename = self.get_filename( filename ) + filename = self.get_filename( filename, migrated_tool_id=migrated_tool_id ) tc.formfile( "1", "file_data", filename ) tc.fv( "1", "space_to_tab", space_to_tab ) tc.submit("runtool_btn") @@ -212,6 +219,7 @@ raise AssertionError, "Invalid hid (%s) created when uploading file %s" % ( hid, filename ) # Wait for upload processing to finish (TODO: this should be done in each test case instead) self.wait() + def upload_url_paste( self, url_paste, ftype='auto', dbkey='unspecified (?)' ): """Pasted data in the upload utility""" self.visit_page( "tool_runner/index?tool_id=upload1" ) @@ -620,6 +628,7 @@ check_str = '1 dataset copied to 1 history' self.check_page_for_string( check_str ) self.home() + def get_hids_in_history( self ): """Returns the list of hid values for items in a history""" data_list = self.get_history_as_data_list() @@ -628,6 +637,7 @@ hid = elem.get('hid') hids.append(hid) return hids + def get_hids_in_histories( self ): """Returns the list of hids values for items in all histories""" data_list = self.get_histories_as_data_list() @@ -643,7 +653,7 @@ fd,temp_prefix = tempfile.mkstemp(prefix='tmp',suffix=suffix) return temp_prefix - def verify_dataset_correctness( self, filename, hid=None, wait=True, maxseconds=120, attributes=None ): + def verify_dataset_correctness( self, filename, hid=None, wait=True, maxseconds=120, attributes=None, migrated_tool_id=None ): """Verifies that the attributes and contents of a history item meet expectations""" if wait: self.wait( maxseconds=maxseconds ) #wait for job to finish @@ -682,7 +692,7 @@ errmsg += str( err ) raise AssertionError( errmsg ) if filename is not None: - local_name = self.get_filename( filename ) + local_name = self.get_filename( filename, migrated_tool_id=migrated_tool_id ) temp_name = self.makeTfname(fname = filename) file( temp_name, 'wb' ).write(data) if self.keepOutdir > '': @@ -716,7 +726,7 @@ else: raise Exception, 'Unimplemented Compare type: %s' % compare if extra_files: - self.verify_extra_files_content( extra_files, elem.get( 'id' ) ) + self.verify_extra_files_content( extra_files, elem.get( 'id' ), migrated_tool_id=migrated_tool_id ) except AssertionError, err: errmsg = 'History item %s different than expected, difference (using %s):\n' % ( hid, compare ) errmsg += str( err ) @@ -735,21 +745,21 @@ os.remove( temp_name ) return temp_local, temp_temp - def verify_extra_files_content( self, extra_files, hda_id ): + def verify_extra_files_content( self, extra_files, hda_id, migrated_tool_id=None ): files_list = [] for extra_type, extra_value, extra_name, extra_attributes in extra_files: if extra_type == 'file': files_list.append( ( extra_name, extra_value, extra_attributes ) ) elif extra_type == 'directory': - for filename in os.listdir( self.get_filename( extra_value ) ): + for filename in os.listdir( self.get_filename( extra_value, migrated_tool_id=migrated_tool_id ) ): files_list.append( ( filename, os.path.join( extra_value, filename ), extra_attributes ) ) else: raise ValueError, 'unknown extra_files type: %s' % extra_type for filename, filepath, attributes in files_list: - self.verify_composite_datatype_file_content( filepath, hda_id, base_name = filename, attributes = attributes ) + self.verify_composite_datatype_file_content( filepath, hda_id, base_name=filename, attributes=attributes, migrated_tool_id=migrated_tool_id ) - def verify_composite_datatype_file_content( self, file_name, hda_id, base_name = None, attributes = None ): - local_name = self.get_filename( file_name ) + def verify_composite_datatype_file_content( self, file_name, hda_id, base_name=None, attributes=None, migrated_tool_id=None ): + local_name = self.get_filename( file_name, migrated_tool_id=migrated_tool_id ) if base_name is None: base_name = os.path.split(file_name)[-1] temp_name = self.makeTfname(fname = base_name) @@ -1005,8 +1015,8 @@ def last_page( self ): return tc.browser.get_html() - def load_cookies( self, file ): - filename = self.get_filename(file) + def load_cookies( self, file, migrated_tool_id=None ): + filename = self.get_filename( file, migrated_tool_id=migrated_tool_id ) tc.load_cookies(filename) def reload_page( self ): diff -r 7ab3012fe281f9219e2323e6c8c9694fc2b2628a -r c510097f7018dbc177513a62c0ca46b4cace0c86 test/functional/test_toolbox.py --- a/test/functional/test_toolbox.py +++ b/test/functional/test_toolbox.py @@ -10,7 +10,7 @@ class ToolTestCase( TwillTestCase ): """Abstract test case that runs tests based on a `galaxy.tools.test.ToolTest`""" - def do_it( self, testdef ): + def do_it( self, testdef, migrated_tool_id=None ): # If the test generation had an error, raise if testdef.error: if testdef.exception: @@ -35,7 +35,12 @@ children = extra.get( 'children', [] ) metadata = extra.get( 'metadata', [] ) composite_data = extra.get( 'composite_data', [] ) - self.upload_file( fname, ftype=extra.get( 'ftype', 'auto' ), dbkey=extra.get( 'dbkey', 'hg17' ), metadata = metadata, composite_data = composite_data ) + self.upload_file( fname, + ftype=extra.get( 'ftype', 'auto' ), + dbkey=extra.get( 'dbkey', 'hg17' ), + metadata=metadata, + composite_data=composite_data, + migrated_tool_id=migrated_tool_id ) print "Uploaded file: ", fname, ", ftype: ", extra.get( 'ftype', 'auto' ), ", extra: ", extra #Post upload attribute editing edit_attributes = extra.get( 'edit_attributes', [] ) @@ -94,7 +99,7 @@ elem_hid = elem.get( 'hid' ) elem_index += 1 try: - self.verify_dataset_correctness( outfile, hid=elem_hid, maxseconds=testdef.maxseconds, attributes=attributes ) + self.verify_dataset_correctness( outfile, hid=elem_hid, maxseconds=testdef.maxseconds, attributes=attributes, migrated_tool_id=migrated_tool_id ) except Exception, e: print >>sys.stderr, self.get_job_stdout( elem.get( 'id' ), format=True ) print >>sys.stderr, self.get_job_stderr( elem.get( 'id' ), format=True ) @@ -138,7 +143,7 @@ expanded_inputs[value.name] = declared_inputs[value.name] return expanded_inputs -def build_tests(): +def build_tests( testing_migrated_tools=False ): """ If the module level variable `toolbox` is set, generate `ToolTestCase` classes for all of its tests and put them into this modules globals() so @@ -148,21 +153,30 @@ return # Push all the toolbox tests to module level G = globals() + # Eliminate all previous tests from G. + for key, val in G.items(): + if key.startswith( 'TestForTool_' ): + del G[ key ] for i, tool_id in enumerate( toolbox.tools_by_id ): tool = toolbox.get_tool( tool_id ) if tool.tests: - # Create a new subclass of ToolTestCase dynamically adding methods - # names test_tool_XXX that run each test defined in the tool. - n = "TestForTool_" + tool.id.replace( ' ', '_' ) - s = ( ToolTestCase, ) - d = dict() + # Create a new subclass of ToolTestCase, dynamically adding methods + # named test_tool_XXX that run each test defined in the tool config. + name = "TestForTool_" + tool.id.replace( ' ', '_' ) + baseclasses = ( ToolTestCase, ) + namespace = dict() for j, testdef in enumerate( tool.tests ): - def make_test_method( td ): + def make_test_method( td, migrated_tool_id=None ): def test_tool( self ): - self.do_it( td ) + self.do_it( td, migrated_tool_id=migrated_tool_id ) return test_tool - m = make_test_method( testdef ) - m.__doc__ = "%s ( %s ) > %s" % ( tool.name, tool.id, testdef.name ) - d['test_tool_%06d' % j] = m - G[ n ] = new.classobj( n, s, d ) - + if testing_migrated_tools: + test_method = make_test_method( testdef, migrated_tool_id=tool.id ) + else: + test_method = make_test_method( testdef ) + test_method.__doc__ = "%s ( %s ) > %s" % ( tool.name, tool.id, testdef.name ) + namespace[ 'test_tool_%06d' % j ] = test_method + # 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 ) + G[ name ] = new_class_obj Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.