commit/galaxy-central: 2 new changesets
2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/34dfad3b8811/ changeset: 34dfad3b8811 user: inithello date: 2013-03-13 17:45:47 summary: Shut down the update manager when the galaxy UniverseApplication's shutdown method is called. affected #: 1 file diff -r 1a68cc9626220afa542f0ac00951511e7eae56bf -r 34dfad3b8811968a7988de90817f499dc7ee860c lib/galaxy/app.py --- a/lib/galaxy/app.py +++ b/lib/galaxy/app.py @@ -106,6 +106,8 @@ if self.config.get_bool( 'enable_tool_shed_check', False ): from tool_shed.galaxy_install import update_manager self.update_manager = update_manager.UpdateManager( self ) + else: + self.update_manager = None # Load proprietary datatype converters and display applications. self.installed_repository_manager.load_proprietary_converters_and_display_applications() # Load datatype display applications defined in local datatypes_conf.xml @@ -166,6 +168,8 @@ self.object_store.shutdown() if self.heartbeat: self.heartbeat.shutdown() + if self.update_manager: + self.update_manager.shutdown() try: # If the datatypes registry was persisted, attempt to # remove the temporary file in which it was written. https://bitbucket.org/galaxy/galaxy-central/commits/9159442d180f/ changeset: 9159442d180f user: inithello date: 2013-03-13 17:48:55 summary: Add repository counts to install and test repository summary output. Add functional tests for repositories with datatype converters. Add functional tests for browsing Galaxy utilities. Add functional tests for the Galaxy update manager. Enhance functional tests to verify behavior when a repository is deleted. Change code style to be compliant with Galaxy team standards. affected #: 13 files diff -r 34dfad3b8811968a7988de90817f499dc7ee860c -r 9159442d180f9f7baf282b93ad70ce6ddbecec32 test/install_and_test_tool_shed_repositories/functional_tests.py --- a/test/install_and_test_tool_shed_repositories/functional_tests.py +++ b/test/install_and_test_tool_shed_repositories/functional_tests.py @@ -754,15 +754,15 @@ if repositories_tested > 0: if repositories_passed: print '# ----------------------------------------------------------------------------------' - print "# Repositories passed:" + print "# %d repositories passed:" % len( repositories_passed ) show_summary_output( repositories_passed ) if repositories_failed: print '# ----------------------------------------------------------------------------------' - print "# Repositories failed:" + print "# %d repositories failed:" % len( repositories_failed ) show_summary_output( repositories_failed ) if repositories_failed_install: print '# ----------------------------------------------------------------------------------' - print "# Repositories not installed correctly:" + print "# %d repositories not installed correctly:" % len( repositories_failed_install ) show_summary_output( repositories_failed_install ) print "####################################################################################" diff -r 34dfad3b8811968a7988de90817f499dc7ee860c -r 9159442d180f9f7baf282b93ad70ce6ddbecec32 test/tool_shed/base/test_db_util.py --- a/test/tool_shed/base/test_db_util.py +++ b/test/tool_shed/base/test_db_util.py @@ -9,15 +9,19 @@ def delete_obj( obj ): sa_session.delete( obj ) sa_session.flush() + def delete_user_roles( user ): for ura in user.roles: sa_session.delete( ura ) sa_session.flush() + def flush( obj ): sa_session.add( obj ) sa_session.flush() + def get_all_repositories(): return sa_session.query( model.Repository ).all() + def get_all_installed_repositories( actually_installed=False ): if actually_installed: return ga_session.query( galaxy.model.ToolShedRepository ) \ @@ -27,38 +31,46 @@ .all() else: return ga_session.query( galaxy.model.ToolShedRepository ).all() + def get_category_by_name( name ): return sa_session.query( model.Category ) \ .filter( model.Category.table.c.name == name ) \ .first() + def get_default_user_permissions_by_role( role ): return sa_session.query( model.DefaultUserPermissions ) \ .filter( model.DefaultUserPermissions.table.c.role_id == role.id ) \ .all() + def get_default_user_permissions_by_user( user ): return sa_session.query( model.DefaultUserPermissions ) \ .filter( model.DefaultUserPermissions.table.c.user_id==user.id ) \ .all() + def get_galaxy_repository_by_name_owner_changeset_revision( repository_name, owner, changeset_revision ): return ga_session.query( galaxy.model.ToolShedRepository ) \ .filter( and_( galaxy.model.ToolShedRepository.table.c.name == repository_name, galaxy.model.ToolShedRepository.table.c.owner == owner, galaxy.model.ToolShedRepository.table.c.changeset_revision == changeset_revision ) ) \ .first() + def get_installed_repository_by_id( repository_id ): return ga_session.query( galaxy.model.ToolShedRepository ) \ .filter( galaxy.model.ToolShedRepository.table.c.id == repository_id ) \ .first() + def get_installed_repository_by_name_owner( repository_name, owner ): return ga_session.query( galaxy.model.ToolShedRepository ) \ .filter( and_( galaxy.model.ToolShedRepository.table.c.name == repository_name, galaxy.model.ToolShedRepository.table.c.owner == owner ) ) \ .first() + def get_private_role( user ): for role in user.all_roles(): if role.name == user.email and role.description == 'Private Role for %s' % user.email: return role raise AssertionError( "Private role not found for user '%s'" % user.email ) + def get_repository_reviews( repository_id, reviewer_user_id=None, changeset_revision=None ): if reviewer_user_id and changeset_revision: reviews = sa_session.query( model.RepositoryReview ) \ @@ -79,6 +91,7 @@ model.RepositoryReview.table.c.deleted == False ) ) \ .all() return reviews + def get_reviews_ordered_by_changeset_revision( repository_id, changelog_tuples, reviewer_user_id=None ): reviews = get_repository_reviews( repository_id, reviewer_user_id=reviewer_user_id ) ordered_reviews = [] @@ -87,16 +100,25 @@ if str( review.changeset_revision ) == str( changeset_hash ): ordered_reviews.append( review ) return ordered_reviews + def get_repository_by_id( repository_id ): return sa_session.query( model.Repository ) \ .filter( model.Repository.table.c.id == repository_id ) \ .first() + def get_repository_downloadable_revisions( repository_id ): revisions = sa_session.query( model.RepositoryMetadata ) \ .filter( and_( model.RepositoryMetadata.table.c.repository_id == repository_id, model.RepositoryMetadata.table.c.downloadable == True ) ) \ .all() return revisions +def get_repository_metadata_for_changeset_revision( repository_id, changeset_revision ): + repository_metadata = sa_session.query( model.RepositoryMetadata ) \ + .filter( and_( model.RepositoryMetadata.table.c.repository_id == repository_id, + model.RepositoryMetadata.table.c.changeset_revision == changeset_revision ) ) \ + .first() + return repository_metadata + def get_repository_review_by_user_id_changeset_revision( user_id, repository_id, changeset_revision ): review = sa_session.query( model.RepositoryReview ) \ .filter( and_( model.RepositoryReview.table.c.user_id == user_id, @@ -104,35 +126,44 @@ model.RepositoryReview.table.c.changeset_revision == changeset_revision ) ) \ .first() return review + def get_role_by_name( role_name ): return sa_session.query( model.Role ) \ .filter( model.Role.table.c.name == role_name ) \ .first() + def get_user( email ): return sa_session.query( model.User ) \ .filter( model.User.table.c.email==email ) \ .first() + def get_user_by_name( username ): return sa_session.query( model.User ) \ .filter( model.User.table.c.username==username ) \ .first() + def mark_obj_deleted( obj ): obj.deleted = True sa_session.add( obj ) sa_session.flush() + def refresh( obj ): sa_session.refresh( obj ) + def ga_refresh( obj ): ga_session.refresh( obj ) + def get_galaxy_private_role( user ): for role in user.all_roles(): if role.name == user.email and role.description == 'Private Role for %s' % user.email: return role raise AssertionError( "Private role not found for user '%s'" % user.email ) + def get_galaxy_user( email ): return ga_session.query( galaxy.model.User ) \ .filter( galaxy.model.User.table.c.email==email ) \ .first() + def get_repository_by_name_and_owner( name, owner_username ): owner = get_user_by_name( owner_username ) repository = sa_session.query( model.Repository ) \ @@ -140,6 +171,7 @@ model.Repository.table.c.user_id == owner.id ) ) \ .first() return repository + def get_repository_metadata_by_repository_id_changeset_revision( repository_id, changeset_revision ): repository_metadata = sa_session.query( model.RepositoryMetadata ) \ .filter( and_( model.RepositoryMetadata.table.c.repository_id == repository_id, diff -r 34dfad3b8811968a7988de90817f499dc7ee860c -r 9159442d180f9f7baf282b93ad70ce6ddbecec32 test/tool_shed/base/twilltestcase.py --- a/test/tool_shed/base/twilltestcase.py +++ b/test/tool_shed/base/twilltestcase.py @@ -11,7 +11,9 @@ log = logging.getLogger( __name__ ) + class ShedTwillTestCase( TwillTestCase ): + def setUp( self ): # Security helper self.security = security.SecurityHelper( id_secret='changethisinproductiontoo' ) @@ -35,36 +37,65 @@ self.galaxy_tool_dependency_dir = os.environ.get( 'GALAXY_TEST_TOOL_DEPENDENCY_DIR' ) self.shed_tools_dict = {} self.home() + def add_repository_review_component( self, **kwd ): url = '/repository_review/create_component?operation=create' self.visit_url( url ) self.submit_form( 1, 'create_component_button', **kwd ) + def browse_category( self, category, strings_displayed=[], strings_not_displayed=[] ): url = '/repository/browse_valid_categories?sort=name&operation=valid_repositories_by_category&id=%s' % \ self.security.encode_id( category.id ) self.visit_url( url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def browse_component_review( self, review, strings_displayed=[], strings_not_displayed=[] ): url = '/repository_review/browse_review?id=%s' % self.security.encode_id( review.id ) self.visit_url( url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + + def browse_custom_datatypes( self, strings_displayed=[], strings_not_displayed=[] ): + url = '/repository/browse_datatypes' + self.visit_url( url ) + self.check_for_strings( strings_displayed, strings_not_displayed ) + def browse_repository( self, repository, strings_displayed=[], strings_not_displayed=[] ): url = '/repository/browse_repository?id=%s' % self.security.encode_id( repository.id ) self.visit_url( url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + + def browse_repository_dependencies( self, strings_displayed=[], strings_not_displayed=[] ): + url = '/repository/browse_repository_dependencies' + self.visit_url( url ) + self.check_for_strings( strings_displayed, strings_not_displayed ) + def browse_tool_shed( self, url, strings_displayed=[], strings_not_displayed=[] ): self.visit_galaxy_url( '/admin_toolshed/browse_tool_shed?tool_shed_url=%s' % url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + + def browse_tool_dependencies( self, strings_displayed=[], strings_not_displayed=[] ): + url = '/repository/browse_tool_dependencies' + self.visit_url( url ) + self.check_for_strings( strings_displayed, strings_not_displayed ) + + def browse_tools( self, strings_displayed=[], strings_not_displayed=[] ): + url = '/repository/browse_tools' + self.visit_url( url ) + self.check_for_strings( strings_displayed, strings_not_displayed ) + def check_count_of_metadata_revisions_associated_with_repository( self, repository, metadata_count ): self.check_repository_changelog( repository ) self.check_string_count_in_page( 'Repository metadata is associated with this change set.', metadata_count ) + def check_for_valid_tools( self, repository, strings_displayed=[], strings_not_displayed=[] ): strings_displayed.append( 'Valid tools' ) self.display_manage_repository_page( repository, strings_displayed, strings_not_displayed ) + def check_galaxy_repository_db_status( self, repository_name, owner, expected_status ): installed_repository = test_db_util.get_installed_repository_by_name_owner( repository_name, owner ) assert installed_repository.status == expected_status, 'Status in database is %s, expected %s' % \ ( installed_repository.status, expected_status ) + def check_galaxy_repository_tool_panel_section( self, repository, expected_tool_panel_section ): metadata = repository.metadata assert 'tools' in metadata, 'Tools not found in metadata: %s' % metadata @@ -83,6 +114,7 @@ tool_panel_section = tool_panel_section_metadata[ tool_guid ][ 0 ][ 'name' ] assert tool_panel_section == expected_tool_panel_section, 'Expected tool panel section %s, found %s\nMetadata: %s\n' % \ ( expected_tool_panel_section, tool_panel_section, metadata ) + def check_installed_repository_tool_dependencies( self, installed_repository, strings_displayed=[], @@ -100,15 +132,18 @@ url = '/admin_toolshed/manage_repository?id=%s' % self.security.encode_id( installed_repository.id ) self.visit_galaxy_url( url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def check_repository_changelog( self, repository, strings_displayed=[], strings_not_displayed=[] ): url = '/repository/view_changelog?id=%s' % self.security.encode_id( repository.id ) self.visit_url( url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def check_repository_dependency( self, repository, depends_on_repository, depends_on_changeset_revision=None, changeset_revision=None ): strings_displayed = [ depends_on_repository.name, depends_on_repository.user.username ] if depends_on_changeset_revision: strings_displayed.append( depends_on_changeset_revision ) self.display_manage_repository_page( repository, changeset_revision=changeset_revision, strings_displayed=strings_displayed ) + def check_repository_metadata( self, repository, tip_only=True ): if tip_only: assert self.tip_has_metadata( repository ) and len( self.get_repository_metadata_revisions( repository ) ) == 1, \ @@ -117,7 +152,8 @@ assert len( self.get_repository_metadata_revisions( repository ) ) > 0, \ 'Repository tip is not a metadata revision: Repository tip - %s, metadata revisions - %s.' % \ ( self.get_repository_tip( repository ), ', '.join( self.get_repository_metadata_revisions( repository ) ) ) - def check_repository_tools_for_changeset_revision( self, repository, changeset_revision ): + + def check_repository_tools_for_changeset_revision( self, repository, changeset_revision, tool_metadata_strings_displayed=[], tool_page_strings_displayed=[] ): ''' Loop through each tool dictionary in the repository metadata associated with the received changeset_revision. For each of these, check for a tools attribute, and load the tool metadata page if it exists, then display that tool's page. @@ -128,20 +164,17 @@ if 'tools' not in metadata: raise AssertionError( 'No tools in %s revision %s.' % ( repository.name, changeset_revision ) ) for tool_dict in metadata[ 'tools' ]: - metadata_strings_displayed = [ tool_dict[ 'guid' ], - tool_dict[ 'version' ], - tool_dict[ 'id' ], - tool_dict[ 'name' ], - tool_dict[ 'description' ], - changeset_revision ] + tool_id = tool_dict[ 'id' ] + tool_xml = tool_dict[ 'tool_config' ] url = '/repository/view_tool_metadata?repository_id=%s&changeset_revision=%s&tool_id=%s' % \ - ( self.security.encode_id( repository.id ), changeset_revision, tool_dict[ 'id' ] ) + ( self.security.encode_id( repository.id ), changeset_revision, tool_id ) self.visit_url( url ) - self.check_for_strings( metadata_strings_displayed ) - self.load_display_tool_page( repository, tool_xml_path=tool_dict[ 'tool_config' ], + self.check_for_strings( tool_metadata_strings_displayed ) + self.load_display_tool_page( repository, tool_xml_path=tool_xml, changeset_revision=changeset_revision, - strings_displayed=[ '%s (version %s)' % ( tool_dict[ 'name' ], tool_dict[ 'version' ] ) ], + strings_displayed=tool_page_strings_displayed, strings_not_displayed=[] ) + def check_repository_invalid_tools_for_changeset_revision( self, repository, changeset_revision, strings_displayed=[], strings_not_displayed=[] ): '''Load the invalid tool page for each invalid tool associated with this changeset revision and verify the received error messages.''' repository_metadata = self.get_repository_metadata_by_changeset_revision( repository, changeset_revision ) @@ -153,6 +186,7 @@ changeset_revision=changeset_revision, strings_displayed=strings_displayed, strings_not_displayed=strings_not_displayed ) + def check_string_count_in_page( self, pattern, min_count, max_count=None ): """Checks the number of 'pattern' occurrences in the current browser page""" page = self.last_page() @@ -167,6 +201,7 @@ errmsg = "%i occurrences of '%s' found (min. %i, max. %i).\npage content written to '%s' " % \ ( pattern_count, pattern, min_count, max_count, fname ) raise AssertionError( errmsg ) + def create_category( self, **kwd ): category = test_db_util.get_category_by_name( kwd[ 'name' ] ) if category is None: @@ -174,6 +209,7 @@ self.submit_form( form_no=1, button="create_category_button", **kwd ) category = test_db_util.get_category_by_name( kwd[ 'name' ] ) return category + def create_checkbox_query_string( self, field_name, value ): ''' From galaxy.web.form_builder.CheckboxField: @@ -197,6 +233,7 @@ return '%s=%s&%s=%s' % ( field_name, field_value, field_name, field_value ) else: return '%s=%s' % ( field_name, field_value ) + def create_repository_complex_dependency( self, repository, xml_filename, depends_on={} ): self.generate_repository_dependency_xml( depends_on[ 'repositories' ], xml_filename, @@ -207,6 +244,7 @@ 'tool_dependencies.xml', filepath=os.path.split( xml_filename )[0], commit_message='Uploaded dependency on %s.' % ', '.join( repo.name for repo in depends_on[ 'repositories' ] ) ) + def create_repository_dependency( self, repository=None, depends_on=[], filepath=None ): dependency_description = '%s depends on %s.' % ( repository.name, ', '.join( repo.name for repo in depends_on ) ) self.generate_repository_dependency_xml( depends_on, @@ -221,6 +259,7 @@ commit_message='Uploaded dependency on %s.' % ', '.join( repo.name for repo in depends_on ), strings_displayed=[], strings_not_displayed=[] ) + def create_repository_review( self, repository, review_contents_dict, changeset_revision=None, copy_from=None): strings_displayed = [] if not copy_from: @@ -242,6 +281,7 @@ ( self.get_repository_tip( repository ), self.security.encode_id( repository.id ), self.security.encode_id( review_id ) ) self.visit_url( url ) self.fill_review_form( review_contents_dict, strings_displayed, strings_not_displayed ) + def create_user_in_galaxy( self, cntrller='user', email='test@bx.psu.edu', password='testuser', username='admin-user', redirect='' ): self.visit_galaxy_url( "/user/create?cntrller=%s&use_panels=False" % cntrller ) tc.fv( '1', 'email', email ) @@ -272,6 +312,7 @@ except: pass return previously_created, username_taken, invalid_username + def delete_files_from_repository( self, repository, filenames=[], strings_displayed=[ 'were deleted from the repository' ], strings_not_displayed=[] ): files_to_delete = [] basepath = self.get_repo_path( repository ) @@ -287,24 +328,38 @@ tc.fv( "1", "selected_files_to_delete", ','.join( files_to_delete ) ) tc.submit( 'select_files_to_delete_button' ) self.check_for_strings( strings_displayed, strings_not_displayed ) + + def delete_repository( self, repository ): + repository_id = self.security.encode_id( repository.id ) + self.visit_url( '/admin/browse_repositories' ) + url = '/admin/browse_repositories?operation=Delete&id=%s' % repository_id + strings_displayed = [ 'Deleted 1 repository', repository.name ] + strings_not_displayed = [] + self.visit_url( url ) + self.check_for_strings( strings_displayed, strings_not_displayed ) + def display_all_workflows( self, strings_displayed=[], strings_not_displayed=[] ): url = '/workflow' self.visit_galaxy_url( url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def display_galaxy_browse_repositories_page( self, strings_displayed=[], strings_not_displayed=[] ): url = '/admin_toolshed/browse_repositories' self.visit_galaxy_url( url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def display_installed_repository_manage_page( self, installed_repository, strings_displayed=[], strings_not_displayed=[] ): url = '/admin_toolshed/manage_repository?id=%s' % self.security.encode_id( installed_repository.id ) self.visit_galaxy_url( url ) strings_displayed.append( installed_repository.installed_changeset_revision ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def display_installed_workflow_image( self, repository, workflow_name, strings_displayed=[], strings_not_displayed=[] ): url = '/admin_toolshed/generate_workflow_image?repository_id=%s&workflow_name=%s' % \ ( self.security.encode_id( repository.id ), tool_shed_encode( workflow_name ) ) self.visit_galaxy_url( url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def display_manage_repository_page( self, repository, changeset_revision=None, strings_displayed=[], strings_not_displayed=[] ): base_url = '/repository/manage_repository?id=%s' % self.security.encode_id( repository.id ) if changeset_revision: @@ -314,10 +369,12 @@ url = base_url self.visit_url( url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def display_repository_clone_page( self, owner_name, repository_name, strings_displayed=[], strings_not_displayed=[] ): url = '/repos/%s/%s' % ( owner_name, repository_name ) self.visit_url( url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def display_repository_file_contents( self, repository, filename, filepath=None, strings_displayed=[], strings_not_displayed=[] ): '''Find a file in the repository and display the contents.''' basepath = self.get_repo_path( repository ) @@ -331,10 +388,12 @@ url = '/repository/get_file_contents?file_path=%s' % os.path.join( relative_path, filename ) self.visit_url( url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def display_reviewed_repositories_owned_by_user( self, strings_displayed=[], strings_not_displayed=[] ): url = '/repository_review/reviewed_repositories_i_own' self.visit_url( url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def edit_repository_categories( self, repository, categories_to_add=[], categories_to_remove=[], restore_original=True ): url = '/repository/manage_repository?id=%s' % self.security.encode_id( repository.id ) self.visit_url( url ) @@ -359,10 +418,12 @@ strings_not_displayed.append( "selected>%s" % category ) tc.submit( "manage_categories_button" ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def display_repository_reviews_by_user( self, user, strings_displayed=[], strings_not_displayed=[] ): url = '/repository_review/repository_reviews_by_user?id=%s' % self.security.encode_id( user.id ) self.visit_url( url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def edit_repository_information( self, repository, **kwd ): url = '/repository/manage_repository?id=%s' % self.security.encode_id( repository.id ) self.visit_url( url ) @@ -381,6 +442,7 @@ strings_displayed.append( self.escape_html( original_information[ input_elem_name ] ) ) tc.submit( "edit_repository_button" ) self.check_for_strings( strings_displayed ) + def escape_html( self, string, unescape=False ): html_entities = [ ('&', 'X' ), ( "'", ''' ), ( '"', '"' ) ] for character, replacement in html_entities: @@ -389,6 +451,7 @@ else: string = string.replace( character, replacement ) return string + def fill_review_form( self, review_contents_dict, strings_displayed=[], strings_not_displayed=[] ): kwd = dict() for label, contents in review_contents_dict.items(): @@ -404,6 +467,7 @@ self.submit_form( 1, 'Workflows__ESEP__review_button', **kwd ) strings_displayed.append( 'Reviews were saved' ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def galaxy_login( self, email='test@bx.psu.edu', password='testuser', username='admin-user', redirect='' ): previously_created, username_taken, invalid_username = \ self.create_user_in_galaxy( email=email, password=password, username=username, redirect=redirect ) @@ -413,11 +477,13 @@ tc.fv( '1', 'redirect', redirect ) tc.fv( '1', 'password', password ) tc.submit( 'login_button' ) + def galaxy_logout( self ): self.home() self.visit_galaxy_url( "/user/logout" ) self.check_page_for_string( "You have been logged out" ) self.home() + def generate_invalid_dependency_xml( self, xml_filename, url, name, owner, changeset_revision, complex=True, package=None, version=None, description=None ): file_path = os.path.split( xml_filename )[0] dependency_entries = [] @@ -440,6 +506,7 @@ repository_dependency_xml = template_parser.safe_substitute( description=description, dependency_lines='\n'.join( dependency_entries ) ) # Save the generated xml to the specified location. file( xml_filename, 'w' ).write( repository_dependency_xml ) + def generate_repository_dependency_xml( self, repositories, xml_filename, dependency_description='', complex=False, package=None, version=None ): file_path = os.path.split( xml_filename )[0] if not os.path.exists( file_path ): @@ -464,11 +531,13 @@ repository_dependency_xml = template_parser.safe_substitute( description=description, dependency_lines='\n'.join( dependency_entries ) ) # Save the generated xml to the specified location. file( xml_filename, 'w' ).write( repository_dependency_xml ) + def generate_temp_path( self, test_script_path, additional_paths=[] ): temp_path = os.path.join( self.tool_shed_test_tmp_dir, test_script_path, os.sep.join( additional_paths ) ) if not os.path.exists( temp_path ): os.makedirs( temp_path ) return temp_path + def get_datatypes_count( self ): url = '/admin/view_datatypes_registry' self.visit_galaxy_url( url ) @@ -477,11 +546,13 @@ if datatypes_count: return datatypes_count.group( 1 ) return None + def get_filename( self, filename, filepath=None ): if filepath is not None: return os.path.abspath( os.path.join( filepath, filename ) ) else: return os.path.abspath( os.path.join( self.file_dir, filename ) ) + def get_last_reviewed_revision_by_user( self, user, repository ): changelog_tuples = self.get_repository_changelog_tuples( repository ) reviews = test_db_util.get_reviews_ordered_by_changeset_revision( repository.id, changelog_tuples, reviewer_user_id = user.id ) @@ -490,6 +561,7 @@ else: last_review = None return last_review + def get_or_create_repository( self, owner=None, strings_displayed=[], strings_not_displayed=[], **kwd ): repository = test_db_util.get_repository_by_name_and_owner( kwd[ 'name' ], owner ) if repository is None: @@ -498,6 +570,7 @@ self.check_for_strings( strings_displayed, strings_not_displayed ) repository = test_db_util.get_repository_by_name_and_owner( kwd[ 'name' ], owner ) return repository + def get_repo_path( self, repository ): # An entry in the hgweb.config file looks something like: repos/test/mira_assembler = database/community_files/000/repo_123 lhs = "repos/%s/%s" % ( repository.user.username, repository.name ) @@ -505,6 +578,7 @@ return self.hgweb_config_manager.get_entry( lhs ) except: raise Exception( "Entry for repository %s missing in hgweb config file %s." % ( lhs, self.hgweb_config_manager.hgweb_config ) ) + def get_repository_changelog_tuples( self, repository ): repo = hg.repository( ui.ui(), self.get_repo_path( repository ) ) changelog_tuples = [] @@ -512,12 +586,14 @@ ctx = repo.changectx( changeset ) changelog_tuples.append( ( ctx.rev(), repo.changectx( changeset ) ) ) return changelog_tuples + def get_repository_datatypes_count( self, repository ): metadata = self.get_repository_metadata( repository )[0].metadata if 'datatypes' not in metadata: return 0 else: return len( metadata[ 'datatypes' ] ) + def get_repository_file_list( self, base_path, current_path=None ): '''Recursively load repository folder contents and append them to a list. Similar to os.walk but via /repository/open_folder.''' if current_path is None: @@ -548,19 +624,20 @@ else: returned_file_list.append( file_dict[ 'title' ] ) return returned_file_list + def get_repository_metadata( self, repository ): return [ metadata_revision for metadata_revision in repository.metadata_revisions ] + def get_repository_metadata_by_changeset_revision( self, repository, changeset_revision ): - found = None - for metadata_revision in repository.metadata_revisions: - if metadata_revision.changeset_revision == changeset_revision: - found = metadata_revision - return found + return test_db_util.get_repository_metadata_for_changeset_revision( repository.id, changeset_revision ) + def get_repository_metadata_revisions( self, repository ): return [ str( repository_metadata.changeset_revision ) for repository_metadata in repository.metadata_revisions ] + def get_repository_tip( self, repository ): repo = hg.repository( ui.ui(), self.get_repo_path( repository ) ) return str( repo.changectx( repo.changelog.tip() ) ) + def get_tools_from_repository_metadata( self, repository, include_invalid=False ): '''Get a list of valid and (optionally) invalid tool dicts from the repository metadata.''' valid_tools = [] @@ -571,6 +648,7 @@ if include_invalid and 'invalid_tools' in repository_metadata.metadata: invalid_tools.append( dict( tools=repository_metadata.metadata[ 'invalid_tools' ], changeset_revision=repository_metadata.changeset_revision ) ) return valid_tools, invalid_tools + def grant_role_to_user( self, user, role ): strings_displayed = [ self.security.encode_id( role.id ), role.name ] strings_not_displayed = [] @@ -587,6 +665,7 @@ self.visit_url( url ) strings_displayed = [ "Role '%s' has been updated" % role.name ] self.check_for_strings( strings_displayed, strings_not_displayed ) + def grant_write_access( self, repository, usernames=[], @@ -601,6 +680,7 @@ tc.fv( "user_access", "allow_push", '+%s' % username ) tc.submit( 'user_access_button' ) self.check_for_strings( post_submit_strings_displayed, post_submit_strings_not_displayed ) + def import_workflow( self, repository, workflow_name, strings_displayed=[], strings_not_displayed=[] ): url = '/admin_toolshed/import_workflow?repository_id=%s&workflow_name=%s' % \ ( self.security.encode_id( repository.id ), tool_shed_encode( workflow_name ) ) @@ -608,6 +688,7 @@ if workflow_name not in strings_displayed: strings_displayed.append( workflow_name ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def initiate_installation_process( self, install_tool_dependencies=False, install_repository_dependencies=True, @@ -633,6 +714,7 @@ ( ','.join( util.listify( repository_ids ) ), encoded_kwd, reinstalling ) self.visit_galaxy_url( url ) return util.listify( repository_ids ) + def install_repositories_from_search_results( self, repositories, install_tool_dependencies=False, strings_displayed=[], strings_not_displayed=[], **kwd ): ''' @@ -658,6 +740,7 @@ self.submit_form( 1, 'select_tool_panel_section_button', **kwd ) repository_ids = self.initiate_installation_process() self.wait_for_repository_installation( repository_ids ) + def install_repository( self, name, owner, category_name, install_tool_dependencies=False, install_repository_dependencies=True, changeset_revision=None, strings_displayed=[], strings_not_displayed=[], preview_strings_displayed=[], @@ -702,6 +785,7 @@ self.check_for_strings( post_submit_strings_displayed, strings_not_displayed ) repository_ids = self.initiate_installation_process( new_tool_panel_section=new_tool_panel_section ) self.wait_for_repository_installation( repository_ids ) + def load_citable_url( self, username, repository_name, @@ -733,20 +817,24 @@ url = '/repository/browse_repositories?user_id=%s&operation=repositories_by_user' % encoded_user_id self.visit_url( url ) self.check_for_strings( strings_displayed_in_iframe, strings_not_displayed_in_iframe ) + def load_display_tool_page( self, repository, tool_xml_path, changeset_revision, strings_displayed=[], strings_not_displayed=[] ): url = '/repository/display_tool?repository_id=%s&tool_config=%s&changeset_revision=%s' % \ ( self.security.encode_id( repository.id ), tool_xml_path, changeset_revision ) self.visit_url( url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def load_galaxy_tool_migrations_page( self, strings_displayed=[], strings_not_displayed=[] ): url = '/admin/review_tool_migration_stages' self.visit_galaxy_url( url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def load_invalid_tool_page( self, repository, tool_xml, changeset_revision, strings_displayed=[], strings_not_displayed=[] ): url = '/repository/load_invalid_tool?repository_id=%s&tool_config=%s&changeset_revision=%s' % \ ( self.security.encode_id( repository.id ), tool_xml, changeset_revision ) self.visit_url( url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def load_workflow_image_in_tool_shed( self, repository, workflow_name, changeset_revision=None, strings_displayed=[], strings_not_displayed=[] ): if not changeset_revision: changeset_revision = self.get_repository_tip( repository ) @@ -757,10 +845,12 @@ ( self.security.encode_id( metadata.id ), tool_shed_encode( workflow_name ) ) self.visit_url( url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def manage_review_components( self, strings_displayed=[], strings_not_displayed=[] ): url = '/repository_review/manage_components' self.visit_url( url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def preview_repository_in_tool_shed( self, name, owner, changeset_revision=None, strings_displayed=[], strings_not_displayed=[] ): repository = test_db_util.get_repository_by_name_and_owner( name, owner ) if not changeset_revision: @@ -768,6 +858,7 @@ self.visit_url( '/repository/preview_tools_in_changeset?repository_id=%s&changeset_revision=%s' % \ ( self.security.encode_id( repository.id ), changeset_revision ) ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def preview_workflow_in_tool_shed( self, repository_name, owner, workflow_name, strings_displayed=[], strings_not_displayed=[] ): repository = test_db_util.get_repository_by_name_and_owner( repository_name, owner ) metadata = self.get_repository_metadata( repository ) @@ -775,11 +866,13 @@ ( tool_shed_encode( workflow_name ), self.security.encode_id( metadata[0].id ) ) self.visit_url( url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def reactivate_repository( self, installed_repository ): url = '/admin_toolshed/browse_repositories?operation=activate+or+reinstall&id=%s' % self.security.encode_id( installed_repository.id ) self.visit_galaxy_url( url ) strings_displayed = [ installed_repository.name, 'repository has been activated' ] self.check_for_strings( strings_displayed, [] ) + def reinstall_repository( self, installed_repository, install_repository_dependencies=True, @@ -807,26 +900,32 @@ new_tool_panel_section ) # Finally, wait until all repositories are in a final state (either Error or Installed) before returning. self.wait_for_repository_installation( repository_ids ) + def repository_is_new( self, repository ): repo = hg.repository( ui.ui(), self.get_repo_path( repository ) ) tip_ctx = repo.changectx( repo.changelog.tip() ) return tip_ctx.rev() < 0 + def reset_installed_repository_metadata( self, repository ): url = '/admin_toolshed/reset_repository_metadata?id=%s' % self.security.encode_id( repository.id ) self.visit_galaxy_url( url ) self.check_for_strings( [ 'Metadata has been reset' ] ) + def reset_metadata_on_selected_repositories( self, repository_ids ): self.visit_url( '/admin/reset_metadata_on_selected_repositories_in_tool_shed' ) kwd = dict( repository_ids=repository_ids ) self.submit_form( form_no=1, button="reset_metadata_on_selected_repositories_button", **kwd ) + def reset_metadata_on_selected_installed_repositories( self, repository_ids ): self.visit_galaxy_url( '/admin_toolshed/reset_metadata_on_selected_installed_repositories' ) kwd = dict( repository_ids=repository_ids ) self.submit_form( form_no=1, button="reset_metadata_on_selected_repositories_button", **kwd ) + def reset_repository_metadata( self, repository ): url = '/repository/reset_all_metadata?id=%s' % self.security.encode_id( repository.id ) self.visit_url( url ) self.check_for_strings( [ 'All repository metadata has been reset.' ] ) + def review_repository( self, repository, review_contents_dict, user=None, changeset_revision=None ): strings_displayed = [] strings_not_displayed = [] @@ -838,10 +937,12 @@ url = '/repository_review/edit_review?id=%s' % self.security.encode_id( review.id ) self.visit_url( url ) self.fill_review_form( review_contents_dict, strings_displayed, strings_not_displayed ) + def revoke_write_access( self, repository, username ): url = '/repository/manage_repository?user_access_button=Remove&id=%s&remove_auth=%s' % \ ( self.security.encode_id( repository.id ), username ) self.visit_url( url ) + def search_for_valid_tools( self, search_fields={}, exact_matches=False, strings_displayed=[], strings_not_displayed=[], from_galaxy=False ): if from_galaxy: galaxy_url = '?galaxy_url=%s' % self.galaxy_url @@ -854,6 +955,7 @@ tc.fv( "1", field_name, search_string ) tc.submit() self.check_for_strings( strings_displayed, strings_not_displayed ) + def send_message_to_repository_owner( self, repository, message, @@ -867,18 +969,30 @@ tc.fv( 1, 'message', message ) tc.submit() self.check_for_strings( post_submit_strings_displayed, post_submit_strings_not_displayed ) + def set_repository_deprecated( self, repository, set_deprecated=True, strings_displayed=[], strings_not_displayed=[] ): url = '/repository/deprecate?id=%s&mark_deprecated=%s' % ( self.security.encode_id( repository.id ), set_deprecated ) self.visit_url( url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def set_repository_malicious( self, repository, set_malicious=True, strings_displayed=[], strings_not_displayed=[] ): self.display_manage_repository_page( repository ) tc.fv( "malicious", "malicious", set_malicious ) tc.submit( "malicious_button" ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def tip_has_metadata( self, repository ): tip = self.get_repository_tip( repository ) return test_db_util.get_repository_metadata_by_repository_id_changeset_revision( repository.id, tip ) + + def undelete_repository( self, repository ): + repository_id = self.security.encode_id( repository.id ) + url = '/admin/browse_repositories?operation=Undelete&id=%s' % repository_id + strings_displayed = [ 'Undeleted 1 repository', repository.name ] + strings_not_displayed = [] + self.visit_url( url ) + self.check_for_strings( strings_displayed, strings_not_displayed ) + def uninstall_repository( self, installed_repository, remove_from_disk=True ): url = '/admin_toolshed/deactivate_or_uninstall_repository?id=%s' % self.security.encode_id( installed_repository.id ) self.visit_galaxy_url( url ) @@ -893,10 +1007,12 @@ else: strings_displayed.append( 'has been deactivated' ) self.check_for_strings( strings_displayed, strings_not_displayed=[] ) + def update_installed_repository( self, installed_repository, strings_displayed=[], strings_not_displayed=[] ): url = '/admin_toolshed/check_for_updates?id=%s' % self.security.encode_id( installed_repository.id ) self.visit_galaxy_url( url ) self.check_for_strings( strings_displayed, strings_not_displayed ) + def upload_file( self, repository, filename, @@ -942,18 +1058,26 @@ # else: # time.sleep( 1 ) # continue + def verify_installed_repositories( self, installed_repositories=[], uninstalled_repositories=[] ): for repository_name, repository_owner in installed_repositories: galaxy_repository = test_db_util.get_installed_repository_by_name_owner( repository_name, repository_owner ) if galaxy_repository: assert galaxy_repository.status == 'Installed', \ 'Repository %s should be installed, but is %s' % ( repository_name, galaxy_repository.status ) + def verify_installed_repository_metadata_unchanged( self, name, owner ): installed_repository = test_db_util.get_installed_repository_by_name_owner( name, owner ) metadata = installed_repository.metadata self.reset_installed_repository_metadata( installed_repository ) new_metadata = installed_repository.metadata assert metadata == new_metadata, 'Metadata for installed repository %s differs after metadata reset.' % name + + def verify_installed_repository_no_tool_panel_section( self, repository ): + '''Verify that there is no 'tool_panel_section' entry in the repository metadata.''' + metadata = repository.metadata + assert 'tool_panel_section' not in metadata, 'Tool panel section incorrectly found in metadata: %s' % metadata + def verify_installed_repository_data_table_entries( self, required_data_table_entries ): # The value of the received required_data_table_entries will be something like: [ 'sam_fa_indexes' ] data_tables = util.parse_xml( self.shed_tool_data_table_conf ) @@ -1006,6 +1130,7 @@ # We better have an entry like: <table comment_char="#" name="sam_fa_indexes"> in our parsed data_tables # or we know that the repository was not correctly installed! assert found, 'No entry for %s in %s.' % ( required_data_table_entry, self.shed_tool_data_table_conf ) + def verify_repository_reviews( self, repository, reviewer=None, strings_displayed=[], strings_not_displayed=[] ): changeset_revision = self.get_repository_tip( repository ) # Verify that the currently logged in user has a repository review for the specified repository, reviewer, and changeset revision. @@ -1017,6 +1142,7 @@ # Load the review and check for the components passed in strings_displayed. review = test_db_util.get_repository_review_by_user_id_changeset_revision( reviewer.id, repository.id, changeset_revision ) self.browse_component_review( review, strings_displayed=strings_displayed ) + def verify_tool_metadata_for_installed_repository( self, installed_repository, strings_displayed=[], strings_not_displayed=[] ): repository_id = self.security.encode_id( installed_repository.id ) for tool in installed_repository.metadata[ 'tools' ]: @@ -1025,6 +1151,7 @@ url = '/admin_toolshed/view_tool_metadata?repository_id=%s&tool_id=%s' % ( repository_id, urllib.quote_plus( tool[ 'id' ] ) ) self.visit_galaxy_url( url ) self.check_for_strings( strings, strings_not_displayed ) + def verify_unchanged_repository_metadata( self, repository ): old_metadata = dict() new_metadata = dict() @@ -1036,14 +1163,17 @@ # Python's dict comparison recursively compares sorted key => value pairs and returns true if any key or value differs, # or if the number of keys differs. assert old_metadata == new_metadata, 'Metadata changed after reset on repository %s.' % repository.name + def view_installed_workflow( self, repository, workflow_name, strings_displayed=[], strings_not_displayed=[] ): url = '/admin_toolshed/view_workflow?repository_id=%s&workflow_name=%s' % \ ( self.security.encode_id( repository.id ), tool_shed_encode( workflow_name ) ) self.visit_galaxy_url( url ) self.check_for_strings( strings, strings_not_displayed ) + def visit_galaxy_url( self, url ): url = '%s%s' % ( self.galaxy_url, url ) self.visit_url( url ) + def wait_for_repository_installation( self, repository_ids ): final_states = [ galaxy_model.ToolShedRepository.installation_status.ERROR, galaxy_model.ToolShedRepository.installation_status.INSTALLED ] diff -r 34dfad3b8811968a7988de90817f499dc7ee860c -r 9159442d180f9f7baf282b93ad70ce6ddbecec32 test/tool_shed/functional/test_0000_basic_repository_features.py --- a/test/tool_shed/functional/test_0000_basic_repository_features.py +++ b/test/tool_shed/functional/test_0000_basic_repository_features.py @@ -5,8 +5,10 @@ repository_description = "Galaxy's filtering tool for test 0000" repository_long_description = "Long description of Galaxy's filtering tool for test 0000" + class TestBasicRepositoryFeatures( ShedTwillTestCase ): '''Test core repository features.''' + def test_0000_initiate_users( self ): """Create necessary user accounts and login as an admin user.""" self.logout() @@ -24,10 +26,12 @@ admin_user = test_db_util.get_user( common.admin_email ) assert admin_user is not None, 'Problem retrieving user with email %s from the database' % common.admin_email admin_user_private_role = test_db_util.get_private_role( admin_user ) + def test_0005_create_categories( self ): """Create categories for this test suite""" self.create_category( name='Test 0000 Basic Repository Features 1', description='Test 0000 Basic Repository Features 1' ) self.create_category( name='Test 0000 Basic Repository Features 2', description='Test 0000 Basic Repository Features 2' ) + def test_0010_create_repository( self ): """Create the filtering repository""" self.logout() @@ -41,6 +45,7 @@ owner=common.test_user_1_name, category_id=self.security.encode_id( category.id ), strings_displayed=strings_displayed ) + def test_0015_edit_repository( self ): """Edit the repository name, description, and long description""" repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) @@ -48,17 +53,20 @@ new_description = "Edited filtering tool" new_long_description = "Edited long description" self.edit_repository_information( repository, repo_name=new_name, description=new_description, long_description=new_long_description ) + def test_0020_change_repository_category( self ): """Change the categories associated with the filtering repository""" repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) self.edit_repository_categories( repository, categories_to_add=[ "Test 0000 Basic Repository Features 2" ], categories_to_remove=[ "Test 0000 Basic Repository Features 1" ] ) + def test_0025_grant_write_access( self ): '''Grant write access to another user''' repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) self.grant_write_access( repository, usernames=[ common.test_user_2_name ] ) self.revoke_write_access( repository, common.test_user_2_name ) + def test_0030_upload_filtering_1_1_0( self ): """Upload filtering_1.1.0.tar to the repository""" repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) @@ -71,6 +79,7 @@ commit_message="Uploaded filtering 1.1.0", strings_displayed=[], strings_not_displayed=[] ) + def test_0035_verify_repository( self ): '''Display basic repository pages''' repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) @@ -78,12 +87,23 @@ self.check_for_valid_tools( repository, strings_displayed=[ 'Filter1' ] ) self.check_count_of_metadata_revisions_associated_with_repository( repository, metadata_count=1 ) tip = self.get_repository_tip( repository ) - self.check_repository_tools_for_changeset_revision( repository, tip ) + tool_guid = '%s/repos/user1/filtering_0000/Filter1/1.1.0' % self.url.replace( 'http://', '' ).rstrip( '/' ) + tool_metadata_strings_displayed = [ tool_guid, + '1.1.0', # The tool version. + 'Filter1', # The tool ID. + 'Filter', # The tool name. + 'data on any column using simple expressions' ] # The tool description. + tool_page_strings_displayed = [ 'Filter (version 1.1.0)' ] + self.check_repository_tools_for_changeset_revision( repository, + tip, + tool_metadata_strings_displayed=tool_metadata_strings_displayed, + tool_page_strings_displayed=tool_page_strings_displayed ) self.check_repository_metadata( repository, tip_only=False ) self.browse_repository( repository, strings_displayed=[ 'Browse %s revision' % repository.name, '(repository tip)' ] ) self.display_repository_clone_page( common.test_user_1_name, repository_name, strings_displayed=[ 'Uploaded filtering 1.1.0', latest_changeset_revision ] ) + def test_0040_alter_repository_states( self ): '''Test toggling the malicious and deprecated repository flags.''' repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) @@ -106,6 +126,7 @@ self.set_repository_deprecated( repository, strings_displayed=[ 'has been marked as not deprecated', 'Mark as deprecated' ], set_deprecated=False ) + def test_0045_display_repository_tip_file( self ): '''Display the contents of filtering.xml in the repository tip revision''' repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) @@ -114,6 +135,7 @@ filepath=None, strings_displayed=[ '1.1.0' ], strings_not_displayed=[] ) + def test_0050_upload_filtering_txt_file( self ): '''Upload filtering.txt file associated with tool version 1.1.0.''' repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) @@ -127,6 +149,7 @@ strings_displayed=[], strings_not_displayed=[] ) self.display_manage_repository_page( repository, strings_displayed=[ 'Readme file for filtering 1.1.0' ] ) + def test_0055_upload_filtering_test_data( self ): '''Upload filtering test data.''' repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) @@ -145,6 +168,7 @@ strings_displayed=[], strings_not_displayed=[] ) self.check_repository_metadata( repository, tip_only=True ) + def test_0060_upload_filtering_2_2_0( self ): '''Upload filtering version 2.2.0''' repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) @@ -157,6 +181,7 @@ commit_message="Uploaded filtering 2.2.0", strings_displayed=[], strings_not_displayed=[] ) + def test_0065_verify_filtering_repository( self ): '''Verify the new tool versions and repository metadata.''' repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) @@ -166,8 +191,19 @@ strings_displayed = [ 'Select a revision' ] self.display_manage_repository_page( repository, strings_displayed=strings_displayed ) self.check_count_of_metadata_revisions_associated_with_repository( repository, metadata_count=2 ) - self.check_repository_tools_for_changeset_revision( repository, tip ) + tool_guid = '%s/repos/user1/filtering_0000/Filter1/2.2.0' % self.url.replace( 'http://', '' ).rstrip( '/' ) + tool_metadata_strings_displayed = [ tool_guid, + '2.2.0', # The tool version. + 'Filter1', # The tool ID. + 'Filter', # The tool name. + 'data on any column using simple expressions' ] # The tool description. + tool_page_strings_displayed = [ 'Filter (version 2.2.0)' ] + self.check_repository_tools_for_changeset_revision( repository, + tip, + tool_metadata_strings_displayed=tool_metadata_strings_displayed, + tool_page_strings_displayed=tool_page_strings_displayed ) self.check_repository_metadata( repository, tip_only=False ) + def test_0070_upload_readme_txt_file( self ): '''Upload readme.txt file associated with tool version 2.2.0.''' repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) @@ -186,22 +222,26 @@ self.display_manage_repository_page( repository, strings_displayed=[ 'Readme file for filtering 1.1.0', 'This is a readme file.' ] ) + def test_0075_delete_readme_txt_file( self ): '''Delete the readme.txt file.''' repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) self.delete_files_from_repository( repository, filenames=[ 'readme.txt' ] ) self.check_count_of_metadata_revisions_associated_with_repository( repository, metadata_count=2 ) self.display_manage_repository_page( repository, strings_displayed=[ 'Readme file for filtering 1.1.0' ] ) + def test_0080_search_for_valid_filter_tool( self ): '''Search for the filtering tool by tool ID, name, and version.''' repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) tip_changeset = self.get_repository_tip( repository ) search_fields = dict( tool_id='Filter1', tool_name='filter', tool_version='2.2.0' ) self.search_for_valid_tools( search_fields=search_fields, strings_displayed=[ tip_changeset ], strings_not_displayed=[] ) + def test_0085_verify_repository_metadata( self ): '''Verify that resetting the metadata does not change it.''' repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) self.verify_unchanged_repository_metadata( repository ) + def test_0090_verify_reserved_repository_name_handling( self ): '''Check that reserved repository names are handled correctly.''' category = test_db_util.get_category_by_name( 'Test 0000 Basic Repository Features 1' ) @@ -212,6 +252,7 @@ owner=common.test_user_1_name, category_id=self.security.encode_id( category.id ), strings_displayed=[ error_message ] ) + def test_0100_verify_reserved_username_handling( self ): '''Check that reserved usernames are handled correctly.''' self.logout() @@ -220,6 +261,7 @@ assert test_user_1 is None, 'Creating user with public name "repos" succeeded.' error_message = 'The term <b>repos</b> is a reserved word in the tool shed, so it cannot be used as a public user name.' self.check_for_strings( strings_displayed=[ error_message ] ) + def test_0105_contact_repository_owner( self ): '''Fill out and submit the form to contact the owner of a repository.''' ''' @@ -239,3 +281,28 @@ strings_displayed=strings_displayed, post_submit_strings_displayed=post_submit_strings_displayed ) + def test_0110_delete_filtering_repository( self ): + '''Delete the filtering_0000 repository and verify that it no longer has any downloadable revisions.''' + repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) + self.logout() + self.login( email=common.admin_email, username=common.admin_username ) + self.delete_repository( repository ) + # Explicitly reload all metadata revisions from the database, to ensure that we have the current status of the downloadable flag. + for metadata_revision in repository.metadata_revisions: + test_db_util.refresh( metadata_revision ) + # Marking a repository as deleted should result in no metadata revisions being downloadable. + assert True not in [ metadata.downloadable for metadata in repository.metadata_revisions ] + + def test_0115_undelete_filtering_repository( self ): + '''Undelete the filtering_0000 repository and verify that it now has two downloadable revisions.''' + repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) + self.logout() + self.login( email=common.admin_email, username=common.admin_username ) + self.undelete_repository( repository ) + # Explicitly reload all metadata revisions from the database, to ensure that we have the current status of the downloadable flag. + for metadata_revision in repository.metadata_revisions: + test_db_util.refresh( metadata_revision ) + # Marking a repository as undeleted should result in all previously downloadable metadata revisions being downloadable again. + # In this case, there should be two downloadable revisions, one for filtering 1.1.0 and one for filtering 2.2.0. + assert True in [ metadata.downloadable for metadata in repository.metadata_revisions ] + assert len( repository.downloadable_revisions ) == 2 diff -r 34dfad3b8811968a7988de90817f499dc7ee860c -r 9159442d180f9f7baf282b93ad70ce6ddbecec32 test/tool_shed/functional/test_0010_repository_with_tool_dependencies.py --- a/test/tool_shed/functional/test_0010_repository_with_tool_dependencies.py +++ b/test/tool_shed/functional/test_0010_repository_with_tool_dependencies.py @@ -5,8 +5,20 @@ repository_description = "Galaxy's freebayes tool" repository_long_description = "Long description of Galaxy's freebayes tool" +''' +1. Create repository freebayes_0020 and upload only the tool XML. +2. Upload the tool_data_table_conf.xml.sample file. +3. Upload sam_fa_indices.loc.sample. +4. Upload a tool_dependencies.xml file that should not parse correctly. +5. Upload a tool_dependencies.xml file that specifies a version that does not match the tool's requirements. +6. Upload a valid tool_dependencies.xml file. +7. Check for the appropriate strings on the manage repository page. +''' + + class TestFreebayesRepository( ShedTwillTestCase ): '''Testing freebayes with tool data table entries, .loc files, and tool dependencies.''' + def test_0000_create_or_login_admin_user( self ): """Create necessary user accounts and login as an admin user.""" self.logout() @@ -19,11 +31,18 @@ admin_user = test_db_util.get_user( common.admin_email ) assert admin_user is not None, 'Problem retrieving user with email %s from the database' % admin_email admin_user_private_role = test_db_util.get_private_role( admin_user ) + def test_0005_create_category( self ): """Create a category for this test suite""" self.create_category( name='Test 0010 Repository With Tool Dependencies', description='Tests for a repository with tool dependencies.' ) + def test_0010_create_freebayes_repository_and_upload_tool_xml( self ): - '''Create freebayes repository and upload freebayes.xml without tool_data_table_conf.xml.sample. This should result in an error message and invalid tool.''' + '''Create freebayes repository and upload only freebayes.xml.''' + ''' + We are at step 1 - Create repository freebayes_0020 and upload only the tool XML. + Uploading only the tool XML file should result in an invalid tool and an error message on + upload, as well as on the manage repository page. + ''' self.logout() self.login( email=common.test_user_1_email, username=common.test_user_1_name ) category = test_db_util.get_category_by_name( 'Test 0010 Repository With Tool Dependencies' ) @@ -44,11 +63,15 @@ strings_not_displayed=[] ) self.display_manage_repository_page( repository, strings_displayed=[ 'Invalid tools' ], strings_not_displayed=[ 'Valid tools' ] ) tip = self.get_repository_tip( repository ) - self.check_repository_invalid_tools_for_changeset_revision( repository, - tip, - strings_displayed=[ 'requires an entry', 'tool_data_table_conf.xml' ] ) + strings_displayed = [ 'requires an entry', 'tool_data_table_conf.xml' ] + self.check_repository_invalid_tools_for_changeset_revision( repository, tip, strings_displayed=strings_displayed ) + def test_0015_upload_missing_tool_data_table_conf_file( self ): '''Upload the missing tool_data_table_conf.xml.sample file to the repository.''' + ''' + We are at step 2 - Upload the tool_data_table_conf.xml.sample file. + Uploading the tool_data_table_conf.xml.sample alone should not make the tool valid, but the error message should change. + ''' repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) self.upload_file( repository, filename='freebayes/tool_data_table_conf.xml.sample', @@ -61,11 +84,15 @@ strings_not_displayed=[] ) self.display_manage_repository_page( repository, strings_displayed=[ 'Invalid tools' ], strings_not_displayed=[ 'Valid tools' ] ) tip = self.get_repository_tip( repository ) - self.check_repository_invalid_tools_for_changeset_revision( repository, - tip, - strings_displayed=[ 'refers to a file', 'sam_fa_indices.loc' ] ) + strings_displayed = [ 'refers to a file', 'sam_fa_indices.loc' ] + self.check_repository_invalid_tools_for_changeset_revision( repository, tip, strings_displayed=strings_displayed ) + def test_0020_upload_missing_sample_loc_file( self ): '''Upload the missing sam_fa_indices.loc.sample file to the repository.''' + ''' + We are at step 3 - Upload the tool_data_table_conf.xml.sample file. + Uploading the tool_data_table_conf.xml.sample alone should not make the tool valid, but the error message should change. + ''' repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) self.upload_file( repository, filename='freebayes/sam_fa_indices.loc.sample', @@ -76,8 +103,13 @@ commit_message='Uploaded tool data table .loc file.', strings_displayed=[], strings_not_displayed=[] ) + def test_0025_upload_malformed_tool_dependency_xml( self ): '''Upload tool_dependencies.xml with bad characters in the readme tag.''' + ''' + We are at step 4 - Upload a tool_dependencies.xml file that should not parse correctly. + Upload a tool_dependencies.xml file that contains <> in the text of the readme tag. This should show an error message about malformed xml. + ''' repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) self.upload_file( repository, filename=os.path.join( 'freebayes', 'malformed_tool_dependencies', 'tool_dependencies.xml' ), @@ -88,8 +120,13 @@ commit_message='Uploaded malformed tool dependency XML.', strings_displayed=[ 'Exception attempting to parse tool_dependencies.xml', 'not well-formed' ], strings_not_displayed=[] ) + def test_0030_upload_invalid_tool_dependency_xml( self ): '''Upload tool_dependencies.xml defining version 0.9.5 of the freebayes package.''' + ''' + We are at step 5 - Upload a tool_dependencies.xml file that specifies a version that does not match the tool's requirements. + This should result in a message about the tool dependency configuration not matching the tool's requirements. + ''' repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) self.upload_file( repository, filename=os.path.join( 'freebayes', 'invalid_tool_dependencies', 'tool_dependencies.xml' ), @@ -100,8 +137,13 @@ commit_message='Uploaded invalid tool dependency XML.', strings_displayed=[ 'The settings for <b>name</b>, <b>version</b> and <b>type</b> from a contained tool configuration' ], strings_not_displayed=[] ) + def test_0035_upload_valid_tool_dependency_xml( self ): '''Upload tool_dependencies.xml defining version 0.9.4_9696d0ce8a962f7bb61c4791be5ce44312b81cf8 of the freebayes package.''' + ''' + We are at step 6 - Upload a valid tool_dependencies.xml file. + At this stage, there should be no errors on the upload page, as every missing or invalid file has been corrected. + ''' repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) self.upload_file( repository, filename=os.path.join( 'freebayes', 'tool_dependencies.xml' ), @@ -112,9 +154,14 @@ commit_message='Uploaded valid tool dependency XML.', strings_displayed=[], strings_not_displayed=[] ) + def test_0040_verify_tool_dependencies( self ): '''Verify that the uploaded tool_dependencies.xml specifies the correct package versions.''' + ''' + We are at step 7 - Check for the appropriate strings on the manage repository page. + Verify that the manage repository page now displays the valid tool dependencies, and that there are no invalid tools shown on the manage page. + ''' repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) - self.display_manage_repository_page( repository, - strings_displayed=[ 'freebayes', '0.9.4_9696d0ce8a9', 'samtools', '0.1.18', 'Valid tools', 'package' ], - strings_not_displayed=[ 'Invalid tools' ] ) + strings_displayed = [ 'freebayes', '0.9.4_9696d0ce8a9', 'samtools', '0.1.18', 'Valid tools', 'package' ] + strings_not_displayed = [ 'Invalid tools' ] + self.display_manage_repository_page( repository, strings_displayed=strings_displayed, strings_not_displayed=strings_not_displayed ) diff -r 34dfad3b8811968a7988de90817f499dc7ee860c -r 9159442d180f9f7baf282b93ad70ce6ddbecec32 test/tool_shed/functional/test_0070_invalid_tool.py --- a/test/tool_shed/functional/test_0070_invalid_tool.py +++ b/test/tool_shed/functional/test_0070_invalid_tool.py @@ -7,8 +7,10 @@ category_name = 'Test 0070 Invalid Tool Revisions' category_description = 'Tests for a repository with invalid tool revisions.' + class TestBismarkRepository( ShedTwillTestCase ): '''Testing bismark with valid and invalid tool entries.''' + def test_0000_create_or_login_admin_user( self ): """Create necessary user accounts and login as an admin user.""" self.logout() @@ -21,6 +23,7 @@ admin_user = test_db_util.get_user( common.admin_email ) assert admin_user is not None, 'Problem retrieving user with email %s from the database' % admin_email admin_user_private_role = test_db_util.get_private_role( admin_user ) + def test_0005_create_category_and_repository( self ): """Create a category for this test suite, then create and populate a bismark repository. It should contain at least one each valid and invalid tool.""" category = self.create_category( name=category_name, description=category_description ) @@ -54,5 +57,15 @@ strings_not_displayed=[] ) valid_revision = self.get_repository_tip( repository ) test_db_util.refresh( repository ) - self.check_repository_tools_for_changeset_revision( repository, valid_revision ) + tool_guid = '%s/repos/user1/bismark_0070/bismark_methylation_extractor/0.7.7.3' % self.url.replace( 'http://', '' ).rstrip( '/' ) + tool_metadata_strings_displayed = [ tool_guid, + '0.7.7.3', # The tool version. + 'bismark_methylation_extractor', # The tool ID. + 'Bismark', # The tool name. + 'methylation extractor' ] # The tool description. + tool_page_strings_displayed = [ 'Bismark (version 0.7.7.3)' ] + self.check_repository_tools_for_changeset_revision( repository, + valid_revision, + tool_metadata_strings_displayed=tool_metadata_strings_displayed, + tool_page_strings_displayed=tool_page_strings_displayed ) self.check_repository_invalid_tools_for_changeset_revision( repository, invalid_revision ) diff -r 34dfad3b8811968a7988de90817f499dc7ee860c -r 9159442d180f9f7baf282b93ad70ce6ddbecec32 test/tool_shed/functional/test_0130_datatype_converters.py --- /dev/null +++ b/test/tool_shed/functional/test_0130_datatype_converters.py @@ -0,0 +1,83 @@ +from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os +import tool_shed.base.test_db_util as test_db_util + +repository_name = 'bed_to_gff_0130' +repository_description = "Converter: BED to GFF" +repository_long_description = "Convert bed to gff" + +category_name = 'Test 0130 Datatype Converters' +category_description = 'Test 0130 Datatype Converters' + +''' +1) Create a populate the bed_to_gff_converter repository +2) Visit the manage repository page and make sure there is the appropriate valid too and datatype +3) Visit the view tool metadata page and make sure that "Display in tool panel" is False +''' + + +class TestDatatypeConverters( ShedTwillTestCase ): + '''Test features related to datatype converters.''' + + def test_0000_initiate_users( self ): + """Create necessary user accounts.""" + self.logout() + self.login( email=common.test_user_1_email, username=common.test_user_1_name ) + test_user_1 = test_db_util.get_user( common.test_user_1_email ) + assert test_user_1 is not None, 'Problem retrieving user with email %s from the database' % test_user_1_email + test_user_1_private_role = test_db_util.get_private_role( test_user_1 ) + self.logout() + self.login( email=common.admin_email, username=common.admin_username ) + admin_user = test_db_util.get_user( common.admin_email ) + assert admin_user is not None, 'Problem retrieving user with email %s from the database' % admin_email + admin_user_private_role = test_db_util.get_private_role( admin_user ) + + def test_0005_create_bed_to_gff_repository( self ): + '''Create and populate bed_to_gff_0130.''' + ''' + We are at step 1 - Create and populate the bed_to_gff_0130 repository. + Create the bed_to_gff_0130 repository and populate it with the files needed for this test. + ''' + category = self.create_category( name=category_name, description=category_description ) + self.logout() + self.login( email=common.test_user_1_email, username=common.test_user_1_name ) + # Create a repository named bed_to_gff_0130 owned by user1. + repository = self.get_or_create_repository( name=repository_name, + description=repository_description, + long_description=repository_long_description, + owner=common.test_user_1_name, + category_id=self.security.encode_id( category.id ), + strings_displayed=[] ) + # Upload bed_to_gff_converter.tar to the repository. + self.upload_file( repository, + filename='bed_to_gff_converter/bed_to_gff_converter.tar', + filepath=None, + valid_tools_only=True, + uncompress_file=False, + remove_repo_files_not_in_tar=False, + commit_message='Uploaded bed_to_gff_converter.tar.', + strings_displayed=[], + strings_not_displayed=[] ) + + def test_0010_verify_tool_and_datatype( self ): + '''Verify that a valid tool and datatype are contained within the repository.''' + ''' + We are at step 2 - Visit the manage repository page and make sure there is the appropriate valid tool and datatype. + There should be a 'Convert BED to GFF' tool and a 'galaxy.datatypes.interval:Bed' datatype with extension 'bed' + ''' + repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) + strings_displayed = [ 'Convert BED to GFF', 'galaxy.datatypes.interval:Bed', 'bed', 'Valid tools', 'Datatypes' ] + strings_not_displayed = [ 'Invalid tools' ] + self.display_manage_repository_page( repository, strings_displayed=strings_displayed, strings_not_displayed=strings_not_displayed ) + + def test_0015_verify_tool_panel_display( self ): + '''Verify that the tool is configured not to be displayed in the tool panel.''' + ''' + We are at step 3 + Datatype converters that are associated with a datatype should have display in tool panel = False in the tool metadata. + ''' + repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) + metadata = self.get_repository_metadata_by_changeset_revision( repository, self.get_repository_tip( repository ) ) + tool_metadata_strings_displayed = '<label>Display in tool panel:</label>\n False' + self.check_repository_tools_for_changeset_revision( repository, + self.get_repository_tip( repository ), + tool_metadata_strings_displayed=tool_metadata_strings_displayed ) diff -r 34dfad3b8811968a7988de90817f499dc7ee860c -r 9159442d180f9f7baf282b93ad70ce6ddbecec32 test/tool_shed/functional/test_0430_browse_utilities.py --- /dev/null +++ b/test/tool_shed/functional/test_0430_browse_utilities.py @@ -0,0 +1,184 @@ +from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os +import tool_shed.base.test_db_util as test_db_util +import logging +log = logging.getLogger(__name__) + +datatypes_repository_name = 'emboss_datatypes_0430' +datatypes_repository_description = 'Galaxy applicable datatypes for EMBOSS for test 0430' +datatypes_repository_long_description = 'Long description of Galaxy applicable datatypes for EMBOSS for test 0430' + +emboss_repository_name = 'emboss_0430' +emboss_repository_description = 'EMBOSS tools for test 0430' +emboss_repository_long_description = 'Long description of EMBOSS tools for test 0430' + +freebayes_repository_name = 'freebayes_0430' +freebayes_repository_description = 'Freebayes tool for test 0430' +freebayes_repository_long_description = 'Long description of Freebayes tool for test 0430' + + +''' +1. Create and populate repositories. +2. Browse Custom Datatypes. +3. Browse Tools. +4. Browse Repository Dependencies. +5. Browse Tool Dependencies. +''' + + +class TestToolShedBrowseUtilities( ShedTwillTestCase ): + '''Test browsing for Galaxy utilities.''' + + def test_0000_initiate_users( self ): + """Create necessary user accounts and login as an admin user.""" + """ + Create all the user accounts that are needed for this test script to run independently of other tests. + Previously created accounts will not be re-created. + """ + self.logout() + self.login( email=common.test_user_1_email, username=common.test_user_1_name ) + test_user_1 = test_db_util.get_user( common.test_user_1_email ) + assert test_user_1 is not None, 'Problem retrieving user with email %s from the database' % common.test_user_1_email + test_user_1_private_role = test_db_util.get_private_role( test_user_1 ) + self.logout() + self.login( email=common.admin_email, username=common.admin_username ) + admin_user = test_db_util.get_user( common.admin_email ) + assert admin_user is not None, 'Problem retrieving user with email %s from the database' % common.admin_email + admin_user_private_role = test_db_util.get_private_role( admin_user ) + + def test_0005_create_datatypes_repository( self ): + """Create and populate the emboss_datatypes_0430 repository""" + """ + We are at step 1. + Create and populate the repository that will contain one or more datatypes. + """ + category = self.create_category( name='Test 0430 Galaxy Utilities', + description='Description of Test 0430 Galaxy Utilities category' ) + self.logout() + self.login( email=common.test_user_1_email, username=common.test_user_1_name ) + strings_displayed = [ 'Repository %s' % "'%s'" % datatypes_repository_name, + 'Repository %s has been created' % "'%s'" % datatypes_repository_name ] + repository = self.get_or_create_repository( name=datatypes_repository_name, + description=datatypes_repository_description, + long_description=datatypes_repository_long_description, + owner=common.test_user_1_name, + category_id=self.security.encode_id( category.id ), + strings_displayed=strings_displayed ) + self.upload_file( repository, + filename='emboss/datatypes/datatypes_conf.xml', + filepath=None, + valid_tools_only=True, + uncompress_file=True, + remove_repo_files_not_in_tar=False, + commit_message='Uploaded datatypes_conf.xml.', + strings_displayed=[], + strings_not_displayed=[] ) + + def test_0010_create_emboss_repository( self ): + """Create and populate the emboss_0430 repository""" + """ + We are at step 1. + Create the emboss_0430 repository, and populate it with tools. + """ + category = self.create_category( name='Test 0430 Galaxy Utilities', + description='Description of Test 0430 Galaxy Utilities category' ) + self.logout() + self.login( email=common.test_user_1_email, username=common.test_user_1_name ) + strings_displayed = [ 'Repository %s' % "'%s'" % emboss_repository_name, + 'Repository %s has been created' % "'%s'" % emboss_repository_name ] + emboss_repository = self.get_or_create_repository( name=emboss_repository_name, + description=emboss_repository_description, + long_description=emboss_repository_long_description, + owner=common.test_user_1_name, + category_id=self.security.encode_id( category.id ), + strings_displayed=strings_displayed ) + self.upload_file( emboss_repository, + filename='emboss/emboss.tar', + filepath=None, + valid_tools_only=True, + uncompress_file=True, + remove_repo_files_not_in_tar=False, + commit_message='Uploaded emboss.tar.', + strings_displayed=[], + strings_not_displayed=[] ) + + def test_0015_create_dependency_on_datatypes_repository( self ): + '''Create a dependency definition file that specifies emboss_datatypes_0430 and upload it to emboss_0430.''' + emboss_repository = test_db_util.get_repository_by_name_and_owner( emboss_repository_name, common.test_user_1_name ) + datatypes_repository = test_db_util.get_repository_by_name_and_owner( datatypes_repository_name, common.test_user_1_name ) + dependency_xml_path = self.generate_temp_path( 'test_0430', additional_paths=[ 'dependencies' ] ) + self.create_repository_dependency( emboss_repository, depends_on=[ datatypes_repository ], filepath=dependency_xml_path ) + self.check_repository_dependency( emboss_repository, datatypes_repository ) + + def test_0020_create_tool_dependency_repository( self ): + """Create and populate the freebayes_0430 repository""" + """ + We are at step 1. + Create and populate the repository that will have a tool dependency defined. + """ + category = self.create_category( name='Test 0430 Galaxy Utilities', + description='Description of Test 0430 Galaxy Utilities category' ) + self.logout() + self.login( email=common.test_user_1_email, username=common.test_user_1_name ) + strings_displayed = [ 'Repository %s' % "'%s'" % freebayes_repository_name, + 'Repository %s has been created' % "'%s'" % freebayes_repository_name ] + repository = self.get_or_create_repository( name=freebayes_repository_name, + description=freebayes_repository_description, + long_description=freebayes_repository_long_description, + owner=common.test_user_1_name, + category_id=self.security.encode_id( category.id ), + strings_displayed=strings_displayed ) + self.upload_file( repository, + filename='freebayes/freebayes.tar', + filepath=None, + valid_tools_only=True, + uncompress_file=True, + remove_repo_files_not_in_tar=False, + commit_message='Uploaded freebayes.tar.', + strings_displayed=[], + strings_not_displayed=[] ) + + def test_0025_browse_custom_datatypes( self ): + '''Load the page to browse custom datatypes.''' + ''' + We are at step 2. + Verify that the uploaded emboss datatypes repository has added to the custom datatypes page. + ''' + repository = test_db_util.get_repository_by_name_and_owner( datatypes_repository_name, common.test_user_1_name ) + changeset_revision = self.get_repository_tip( repository ) + strings_displayed = [ 'equicktandem', 'est2genome', 'supermatcher', 'galaxy.datatypes.data:Text', changeset_revision, 'user1', 'emboss_datatypes_0430' ] + self.browse_custom_datatypes( strings_displayed=strings_displayed ) + + def test_0030_browse_tools( self ): + '''Load the page to browse tools.''' + ''' + We are at step 3. + Verify the existence of emboss tools in the browse tools page. + ''' + repository = test_db_util.get_repository_by_name_and_owner( emboss_repository_name, common.test_user_1_name ) + changeset_revision = self.get_repository_tip( repository ) + strings_displayed = [ 'EMBOSS', 'antigenic1', '5.0.0', changeset_revision, 'user1', 'emboss_0430' ] + self.browse_tools( strings_displayed=strings_displayed ) + + def test_0035_browse_repository_dependencies( self ): + '''Browse repository dependencies and look for a dependency on emboss_datatypes_0430.''' + ''' + We are at step 3. + Verify that the browse repository dependencies page shows emboss_datatypes_0430 as a dependency of emboss_0430. + ''' + emboss_repository = test_db_util.get_repository_by_name_and_owner( emboss_repository_name, common.test_user_1_name ) + datatypes_repository = test_db_util.get_repository_by_name_and_owner( datatypes_repository_name, common.test_user_1_name ) + datatypes_changeset_revision = self.get_repository_tip( datatypes_repository ) + emboss_changeset_revision = self.get_repository_tip( emboss_repository ) + strings_displayed = [ datatypes_changeset_revision, emboss_changeset_revision, 'emboss_datatypes_0430', 'user1', 'emboss_0430' ] + self.browse_repository_dependencies( strings_displayed=strings_displayed ) + + def test_0040_browse_tool_dependencies( self ): + '''Browse tool dependencies and look for the right versions of freebayes and samtools.''' + ''' + We are at step 4. + Verify that the browse tool dependencies page shows the correct dependencies defined for freebayes_0430. + ''' + freebayes_repository = test_db_util.get_repository_by_name_and_owner( freebayes_repository_name, common.test_user_1_name ) + freebayes_changeset_revision = self.get_repository_tip( freebayes_repository ) + strings_displayed = [ freebayes_changeset_revision, 'freebayes_0430', 'user1', '0.9.4_9696d0ce8a96', 'freebayes', 'samtools', '0.1.18' ] + self.browse_tool_dependencies( strings_displayed=strings_displayed ) diff -r 34dfad3b8811968a7988de90817f499dc7ee860c -r 9159442d180f9f7baf282b93ad70ce6ddbecec32 test/tool_shed/functional/test_1000_install_basic_repository.py --- a/test/tool_shed/functional/test_1000_install_basic_repository.py +++ b/test/tool_shed/functional/test_1000_install_basic_repository.py @@ -1,8 +1,10 @@ from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os import tool_shed.base.test_db_util as test_db_util + class BasicToolShedFeatures( ShedTwillTestCase ): '''Test installing a basic repository.''' + def test_0000_initiate_users( self ): """Create necessary user accounts.""" self.logout() @@ -20,6 +22,7 @@ galaxy_admin_user = test_db_util.get_galaxy_user( common.admin_email ) assert galaxy_admin_user is not None, 'Problem retrieving user with email %s from the database' % common.admin_email galaxy_admin_user_private_role = test_db_util.get_galaxy_private_role( galaxy_admin_user ) + def test_0005_ensure_repositories_and_categories_exist( self ): '''Create the 0000 category and upload the filtering repository to it, if necessary.''' category = self.create_category( name='Test 0000 Basic Repository Features 1', description='Test 0000 Basic Repository Features 1' ) @@ -68,6 +71,7 @@ commit_message='Uploaded readme for 2.2.0', strings_displayed=[], strings_not_displayed=[] ) + def test_0010_browse_tool_sheds( self ): """Browse the available tool sheds in this Galaxy instance.""" self.galaxy_logout() @@ -75,13 +79,16 @@ self.visit_galaxy_url( '/admin_toolshed/browse_tool_sheds' ) self.check_page_for_string( 'Embedded tool shed for functional tests' ) self.browse_tool_shed( url=self.url, strings_displayed=[ 'Test 0000 Basic Repository Features 1', 'Test 0000 Basic Repository Features 2' ] ) + def test_0015_browse_test_0000_category( self ): '''Browse the category created in test 0000. It should contain the filtering_0000 repository also created in that test.''' category = test_db_util.get_category_by_name( 'Test 0000 Basic Repository Features 1' ) self.browse_category( category, strings_displayed=[ 'filtering_0000' ] ) + def test_0020_preview_filtering_repository( self ): '''Load the preview page for the filtering_0000 repository in the tool shed.''' self.preview_repository_in_tool_shed( 'filtering_0000', common.test_user_1_name, strings_displayed=[ 'filtering_0000', 'Valid tools' ] ) + def test_0025_install_filtering_repository( self ): self.install_repository( 'filtering_0000', common.test_user_1_name, @@ -97,6 +104,24 @@ strings_displayed.extend( [ 'Installed tool shed repository', 'Valid tools', 'Filter1' ] ) self.display_installed_repository_manage_page( installed_repository, strings_displayed=strings_displayed ) self.verify_tool_metadata_for_installed_repository( installed_repository ) - def test_0030_verify_installed_repository_metadata( self ): + + def test_0030_install_filtering_repository_again( self ): + '''Attempt to install the already installed filtering repository, and check for the resulting error message.''' + installed_repository = test_db_util.get_installed_repository_by_name_owner( 'filtering_0000', common.test_user_1_name ) + post_submit_strings_displayed = [ installed_repository.name, + installed_repository.owner, + installed_repository.installed_changeset_revision, + 'was previously installed', + 'to manage the repository' ] + self.install_repository( 'filtering_0000', + common.test_user_1_name, + 'Test 0000 Basic Repository Features 1', + post_submit_strings_displayed=post_submit_strings_displayed ) + strings_displayed = [ 'filtering_0000', + 'user1', + installed_repository.installed_changeset_revision ] + self.display_galaxy_browse_repositories_page( strings_displayed=strings_displayed ) + + def test_0035_verify_installed_repository_metadata( self ): '''Verify that resetting the metadata on an installed repository does not change the metadata.''' self.verify_installed_repository_metadata_unchanged( 'filtering_0000', common.test_user_1_name ) diff -r 34dfad3b8811968a7988de90817f499dc7ee860c -r 9159442d180f9f7baf282b93ad70ce6ddbecec32 test/tool_shed/functional/test_1130_datatype_converters.py --- /dev/null +++ b/test/tool_shed/functional/test_1130_datatype_converters.py @@ -0,0 +1,94 @@ +from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os +import tool_shed.base.test_db_util as test_db_util + +repository_name = 'bed_to_gff_0130' +repository_description = "Converter: BED to GFF" +repository_long_description = "Convert bed to gff" + +category_name = 'Test 0130 Datatype Converters' +category_description = 'Test 0130 Datatype Converters' + +''' +1) Install the bed_to_gff_converter repository. +2) Make sure the page section to select a tool panel section is NOT displayed since the tool will not be displayed in the Galaxy tool panel. +3) Make sure the bed_to_gff_converter tool is not displayed in the tool panel. +''' + + +class TestDatatypeConverters( ShedTwillTestCase ): + '''Test features related to datatype converters.''' + + def test_0000_initiate_users( self ): + """Create necessary user accounts.""" + self.galaxy_logout() + self.galaxy_login( email=common.admin_email, username=common.admin_username ) + galaxy_admin_user = test_db_util.get_galaxy_user( common.admin_email ) + assert galaxy_admin_user is not None, 'Problem retrieving user with email %s from the database' % common.admin_email + galaxy_admin_user_private_role = test_db_util.get_galaxy_private_role( galaxy_admin_user ) + self.logout() + self.login( email=common.test_user_1_email, username=common.test_user_1_name ) + test_user_1 = test_db_util.get_user( common.test_user_1_email ) + assert test_user_1 is not None, 'Problem retrieving user with email %s from the database' % test_user_1_email + test_user_1_private_role = test_db_util.get_private_role( test_user_1 ) + self.logout() + self.login( email=common.admin_email, username=common.admin_username ) + admin_user = test_db_util.get_user( common.admin_email ) + assert admin_user is not None, 'Problem retrieving user with email %s from the database' % admin_email + admin_user_private_role = test_db_util.get_private_role( admin_user ) + + def test_0005_create_bed_to_gff_repository( self ): + '''Create and populate bed_to_gff_0130.''' + category = self.create_category( name=category_name, description=category_description ) + self.logout() + self.login( email=common.test_user_1_email, username=common.test_user_1_name ) + # Create a repository named bed_to_gff_0130 owned by user1. + repository = self.get_or_create_repository( name=repository_name, + description=repository_description, + long_description=repository_long_description, + owner=common.test_user_1_name, + category_id=self.security.encode_id( category.id ), + strings_displayed=[] ) + if self.repository_is_new( repository ): + # Upload bed_to_gff_converter.tar to the repository, if the repository is new. + self.upload_file( repository, + filename='bed_to_gff_converter/bed_to_gff_converter.tar', + filepath=None, + valid_tools_only=True, + uncompress_file=False, + remove_repo_files_not_in_tar=False, + commit_message='Uploaded bed_to_gff_converter.tar.', + strings_displayed=[], + strings_not_displayed=[] ) + + def test_0010_install_datatype_converter_to_galaxy( self ): + '''Install bed_to_gff_converter_0130 into the running Galaxy instance.''' + ''' + We are at step 1 - Install the bed_to_gff_converter repository. + Install bed_to_gff_converter_0130, checking that the option to select the tool panel section is *not* displayed. + ''' + self.galaxy_logout() + self.galaxy_login( email=common.admin_email, username=common.admin_username ) + repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) + preview_strings_displayed = [ repository.name, self.get_repository_tip( repository ) ] + strings_displayed = [ 'Choose the configuration file' ] + strings_not_displayed = [ 'tool panel section' ] + self.install_repository( repository_name, + common.test_user_1_name, + category_name, + install_tool_dependencies=False, + preview_strings_displayed=preview_strings_displayed, + strings_displayed=strings_displayed, + strings_not_displayed=strings_not_displayed, + post_submit_strings_displayed=[ repository.name, 'new' ], + includes_tools_for_display_in_tool_panel=False ) + + def test_0015_uninstall_and_verify_tool_panel_section( self ): + '''Uninstall bed_to_gff_converter_0130 and verify that the saved tool_panel_section is None.''' + ''' + We are at step 3 - Make sure the bed_to_gff_converter tool is not displayed in the tool panel. + The previous tool panel section for a tool is only recorded in the metadata when a repository is uninstalled, + so we have to uninstall it first, then verify that it was not assigned a tool panel section. + ''' + repository = test_db_util.get_installed_repository_by_name_owner( repository_name, common.test_user_1_name ) + self.uninstall_repository( repository, remove_from_disk=True ) + self.verify_installed_repository_no_tool_panel_section( repository ) diff -r 34dfad3b8811968a7988de90817f499dc7ee860c -r 9159442d180f9f7baf282b93ad70ce6ddbecec32 test/tool_shed/functional/test_1410_update_manager.py --- /dev/null +++ b/test/tool_shed/functional/test_1410_update_manager.py @@ -0,0 +1,125 @@ +from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os +import tool_shed.base.test_db_util as test_db_util +import logging, time +log = logging.getLogger(__name__) + +repository_name = 'filtering_1410' +repository_description = "Galaxy's filtering tool" +repository_long_description = "Long description of Galaxy's filtering repository" + +category_name = 'Test 1410 - Galaxy Update Manager' +category_description = 'Functional test suite to test the update manager.' + +''' +1. Create and populate the filtering_1410 repository. +2. Install filtering_1410 to Galaxy. +3. Upload a readme file. +4. Verify that the browse page now shows an update available. +''' + + +class TestUpdateManager( ShedTwillTestCase ): + '''Test the Galaxy update manager.''' + + def test_0000_initiate_users( self ): + """Create necessary user accounts and login as an admin user.""" + """ + Create all the user accounts that are needed for this test script to run independently of other tests. + Previously created accounts will not be re-created. + """ + self.logout() + self.login( email=common.test_user_1_email, username=common.test_user_1_name ) + test_user_1 = test_db_util.get_user( common.test_user_1_email ) + assert test_user_1 is not None, 'Problem retrieving user with email %s from the database' % common.test_user_1_email + test_user_1_private_role = test_db_util.get_private_role( test_user_1 ) + self.logout() + self.login( email=common.admin_email, username=common.admin_username ) + admin_user = test_db_util.get_user( common.admin_email ) + assert admin_user is not None, 'Problem retrieving user with email %s from the database' % common.admin_email + admin_user_private_role = test_db_util.get_private_role( admin_user ) + self.galaxy_logout() + self.galaxy_login( email=common.admin_email, username=common.admin_username ) + galaxy_admin_user = test_db_util.get_galaxy_user( common.admin_email ) + assert galaxy_admin_user is not None, 'Problem retrieving user with email %s from the database' % common.admin_email + galaxy_admin_user_private_role = test_db_util.get_galaxy_private_role( galaxy_admin_user ) + + def test_0005_create_filtering_repository( self ): + '''Create and populate the filtering_1410 repository.''' + ''' + We are at step 1 - Create and populate the filtering_1410 repository. + Create filtering_1410 and upload the tool tarball to it. + ''' + category = self.create_category( name=category_name, description=category_description ) + self.logout() + self.login( email=common.test_user_1_email, username=common.test_user_1_name ) + repository = self.get_or_create_repository( name=repository_name, + description=repository_description, + long_description=repository_long_description, + owner=common.test_user_1_name, + category_id=self.security.encode_id( category.id ) ) + self.upload_file( repository, + filename='filtering/filtering_1.1.0.tar', + filepath=None, + valid_tools_only=True, + uncompress_file=True, + remove_repo_files_not_in_tar=True, + commit_message="Uploaded filtering 1.1.0", + strings_displayed=[], + strings_not_displayed=[] ) + + def test_0010_install_filtering_repository( self ): + '''Install the filtering_1410 repository.''' + ''' + We are at step 2 - Install filtering_1410 to Galaxy. + Install the filtering repository to Galaxy. + ''' + self.galaxy_logout() + self.galaxy_login( email=common.admin_email, username=common.admin_username ) + self.install_repository( 'filtering_1410', + common.test_user_1_name, + category_name, + new_tool_panel_section='test_1410' ) + installed_repository = test_db_util.get_installed_repository_by_name_owner( 'filtering_1410', common.test_user_1_name ) + strings_displayed = [ 'filtering_1410', + "Galaxy's filtering tool", + 'user1', + self.url.replace( 'http://', '' ), + installed_repository.installed_changeset_revision ] + self.display_galaxy_browse_repositories_page( strings_displayed=strings_displayed ) + strings_displayed.extend( [ 'Installed tool shed repository', 'Valid tools', 'Filter1' ] ) + self.display_installed_repository_manage_page( installed_repository, strings_displayed=strings_displayed ) + self.verify_tool_metadata_for_installed_repository( installed_repository ) + + def test_0015_upload_readme_file( self ): + '''Upload readme.txt to filtering_1410.''' + ''' + We are at step 3 - Upload a readme file. + Upload readme.txt. This will have the effect of making the installed changeset revision not be the most recent downloadable revision, + but without generating a second downloadable revision. Then sleep for 3 seconds to make sure the update manager picks up the new + revision. + ''' + self.logout() + self.login( email=common.test_user_1_email, username=common.test_user_1_name ) + repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) + self.upload_file( repository, + filename='readme.txt', + filepath=None, + valid_tools_only=True, + uncompress_file=True, + remove_repo_files_not_in_tar=False, + commit_message="Uploaded readme.txt", + strings_displayed=[], + strings_not_displayed=[] ) + + def test_0020_check_for_displayed_update( self ): + '''Browse installed repositories and verify update.''' + ''' + We are at step 4 - Verify that the browse page now shows an update available. + The browse page should now show filtering_1410 as installed, but with a yellow box indicating that there is an update available. + ''' + # Wait 3 seconds, just to be sure we're past hours_between_check. + time.sleep( 3 ) + self.galaxy_logout() + self.galaxy_login( email=common.admin_email, username=common.admin_username ) + self.display_galaxy_browse_repositories_page( strings_displayed=[ 'state-color-running' ] ) + diff -r 34dfad3b8811968a7988de90817f499dc7ee860c -r 9159442d180f9f7baf282b93ad70ce6ddbecec32 test/tool_shed/functional_tests.py --- a/test/tool_shed/functional_tests.py +++ b/test/tool_shed/functional_tests.py @@ -278,8 +278,10 @@ database_connection = galaxy_database_connection, database_engine_option_pool_size = '10', datatype_converters_config_file = "datatype_converters_conf.xml.sample", + enable_tool_shed_check = True, file_path = galaxy_file_path, global_conf = global_conf, + hours_between_check = 0.001, id_secret = 'changethisinproductiontoo', job_queue_workers = 5, log_destination = "stdout", diff -r 34dfad3b8811968a7988de90817f499dc7ee860c -r 9159442d180f9f7baf282b93ad70ce6ddbecec32 test/tool_shed/test_data/bed_to_gff_converter/bed_to_gff_converter.tar Binary file test/tool_shed/test_data/bed_to_gff_converter/bed_to_gff_converter.tar has changed 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.
participants (1)
-
commits-noreply@bitbucket.org