1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/3a2211dc42f1/ changeset: 3a2211dc42f1 user: inithello date: 2013-01-16 19:19:45 summary: Tool shed functional test enhancements. Tests for installing repositories via the tool search. Tests for reviewing repository components. affected #: 16 files diff -r 974d7c41b8dfb7e77c6dfa24da05b31d684fd2e6 -r 3a2211dc42f15e0bd357de6abb7dca73221854c7 test/tool_shed/base/common.py --- a/test/tool_shed/base/common.py +++ b/test/tool_shed/base/common.py @@ -8,6 +8,16 @@ test_user_1_email = 'test-1@bx.psu.edu' test_user_1_name = 'user1' +test_user_2 = None +test_user_2_private_role = None +test_user_2_email = 'test-2@bx.psu.edu' +test_user_2_name = 'user2' + +test_user_3 = None +test_user_3_private_role = None +test_user_3_email = 'test-3@bx.psu.edu' +test_user_3_name = 'user3' + new_repository_dependencies_xml = '''<?xml version="1.0"?><repositories${description}> ${dependency_lines} diff -r 974d7c41b8dfb7e77c6dfa24da05b31d684fd2e6 -r 3a2211dc42f15e0bd357de6abb7dca73221854c7 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 @@ -61,6 +61,17 @@ return sa_session.query( model.Repository ) \ .filter( model.Repository.table.c.id == repository_id ) \ .first() +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, + model.RepositoryReview.table.c.repository_id == repository_id, + 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 ) \ diff -r 974d7c41b8dfb7e77c6dfa24da05b31d684fd2e6 -r 3a2211dc42f15e0bd357de6abb7dca73221854c7 test/tool_shed/base/twilltestcase.py --- a/test/tool_shed/base/twilltestcase.py +++ b/test/tool_shed/base/twilltestcase.py @@ -35,11 +35,19 @@ self.galaxy_tool_dependency_dir = None # 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_repository( self, repository, strings_displayed=[], strings_not_displayed=[] ): url = '/repository/browse_repository?id=%s' % self.security.encode_id( repository.id ) self.visit_url( url ) @@ -173,6 +181,23 @@ self.submit_form( form_no=1, button="create_category_button", **kwd ) return test_db_util.get_category_by_name( kwd[ 'name' ] ) def create_checkbox_query_string( self, field_name, value ): + ''' + From galaxy.web.form_builder.CheckboxField: + The hidden field is necessary because if the check box is not checked on the form, it will + not be included in the request params. The hidden field ensure that this will happen. When + parsing the request, the value 'true' in the hidden field actually means it is NOT checked. + See the is_checked() method below. The prefix is necessary in each case to ensure functional + correctness when the param is inside a conditional. + + This may look strange upon initial inspection, but see the comments in the get_html() method + above for clarification. Basically, if value is not True, then it will always be a list with + 2 input fields ( a checkbox and a hidden field ) if the checkbox is checked. If it is not + checked, then value will be only the hidden field. + + The create_checkbox_query_string method emulates the described behavior with URL query parameters. + This is currently necessary because twill does not correctly parse certain forms, so the test + method has to visit the intended form target "manually". + ''' field_value = str( value ).lower() if value: return '%s=%s&%s=%s' % ( field_name, field_value, field_name, field_value ) @@ -187,6 +212,27 @@ 'repository_dependencies.xml', filepath=filepath, commit_message='Uploaded dependency on %s.' % ', '.join( repo.name for repo in depends_on ) ) + def create_repository_review( self, repository, review_contents_dict, changeset_revision=None, copy_from=None): + strings_displayed = [] + if not copy_from: + strings_displayed.append( 'Begin your review' ) + strings_not_displayed = [] + kwd = dict() + if not changeset_revision: + changeset_revision = self.get_repository_tip( repository ) + url = '/repository_review/create_review?changeset_revision=%s&id=%s' % ( changeset_revision, self.security.encode_id( repository.id ) ) + self.visit_url( url ) + self.check_for_strings( strings_displayed, strings_not_displayed ) + strings_displayed = [] + if copy_from: + old_changeset_revision, review_id = copy_from + strings_displayed = [ 'You have elected to create a new review', 'Select previous revision', changeset_revision ] + self.check_for_strings( strings_displayed ) + strings_displayed = [] + url = '/repository_review/create_review?changeset_revision=%s&id=%s&previous_review_id=%s' % \ + ( 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 ) @@ -293,6 +339,10 @@ 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 ) @@ -317,6 +367,10 @@ 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 ) @@ -343,6 +397,21 @@ 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(): + strings_displayed.append( label ) + if contents: + kwd[ '%s__ESEP__comment' % label ] = contents[ 'comment' ] + kwd[ '%s__ESEP__rating' % label ] = contents[ 'rating' ] + if 'private' in contents: + kwd[ '%s__ESEP__private' % label ] = contents[ 'private' ] + kwd[ '%s__ESEP__approved' % label ] = contents[ 'approved' ] + else: + kwd[ '%s__ESEP__approved' % label ] = 'not_applicable' + 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 ) @@ -409,7 +478,7 @@ raise Exception( "Entry for repository %s missing in hgweb config file %s." % ( lhs, self.hgweb_config_manager.hgweb_config ) ) def get_repository_changelog( self, repository ): repo = hg.repository( ui.ui(), self.get_repo_path( repository ) ) - return [repo.changectx( changeset ) for changeset in repo.changelog ] + return [ ( repo.changectx( changeset ), changeset ) for changeset in repo.changelog ] def get_repository_datatypes_count( self, repository ): metadata = self.get_repository_metadata( repository )[0].metadata if 'datatypes' not in metadata: @@ -469,6 +538,22 @@ 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 = [] + self.visit_url( '/admin/roles' ) + self.check_for_strings( strings_displayed, strings_not_displayed ) + url = '/admin/roles?operation=manage+users+and+groups&id=%s' % self.security.encode_id( role.id ) + self.visit_url( url ) + strings_displayed = [ common.test_user_1_email, common.test_user_2_email ] + self.check_for_strings( strings_displayed, strings_not_displayed ) + # As elsewhere, twill limits the possibility of submitting the form, this time due to not executing the javascript + # attached to the role selection form. Visit the action url directly with the necessary parameters. + url = '/admin/manage_users_and_groups_for_role?id=%s&in_users=%d&operation=manage+users+and+groups&role_members_edit_button=Save' % \ + ( self.security.encode_id( role.id ), user.id ) + 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=[], strings_displayed=[], strings_not_displayed=[] ): self.display_manage_repository_page( repository ) tc.fv( "3", "allow_push", '-Select one' ) @@ -508,10 +593,38 @@ ( ','.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, strings_displayed=[], strings_not_displayed=[], **kwd ): + ''' + Normally, it would be possible to check the appropriate boxes in the search results, and click the install button. This works + in a browser, but Twill manages to lose the 'toolshedgalaxyurl' cookie between one page and the next, so it's necessary to work + around this by explicitly visiting the prepare_for_install method on the Galaxy side. + ''' + url = '/admin_toolshed/prepare_for_install?tool_shed_url=%s&repository_ids=%s&changeset_revisions=%s' % \ + ( self.url, ','.join( self.security.encode_id( repository.id ) for repository in repositories ), \ + ','.join( self.get_repository_tip( repository ) for repository in repositories ) ) + self.visit_galaxy_url( url ) + self.check_for_strings( strings_displayed, strings_not_displayed ) + if 'install_tool_dependencies' in self.last_page(): + form = tc.browser.get_form( 'select_tool_panel_section' ) + checkbox = form.find_control( id="install_tool_dependencies" ) + checkbox.disabled = False + if 'install_tool_dependencies' in kwd: + install_tool_dependencies = kwd[ 'install_tool_dependencies' ] + del kwd[ 'install_tool_dependencies' ] + else: + install_tool_dependencies = False + if install_tool_dependencies: + checkbox.selected = True + else: + checkbox.selected = False + 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=[], - post_submit_strings_displayed=[], new_tool_panel_section=None, **kwd ): + post_submit_strings_displayed=[], new_tool_panel_section=None, includes_tools=True, + **kwd ): self.browse_tool_shed( url=self.url ) self.browse_category( test_db_util.get_category_by_name( category_name ) ) self.preview_repository_in_tool_shed( name, owner, strings_displayed=preview_strings_displayed ) @@ -539,8 +652,9 @@ kwd[ 'shed_tool_conf' ] = self.shed_tool_conf if new_tool_panel_section: kwd[ 'new_tool_panel_section' ] = new_tool_panel_section - self.submit_form( 1, 'select_tool_panel_section_button', **kwd ) - self.check_for_strings( post_submit_strings_displayed, strings_not_displayed ) + if includes_tools: + self.submit_form( 1, 'select_tool_panel_section_button', **kwd ) + 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_invalid_tool_page( self, repository, tool_xml, changeset_revision, strings_displayed=[], strings_not_displayed=[] ): @@ -563,6 +677,10 @@ ( 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: @@ -587,31 +705,19 @@ install_repository_dependencies=True, install_tool_dependencies=False, no_changes=True, - new_tool_panel_section='' ): + new_tool_panel_section='', + strings_displayed=[], + strings_not_displayed=[] ): url = '/admin_toolshed/reselect_tool_panel_section?id=%s' % self.security.encode_id( installed_repository.id ) self.visit_galaxy_url( url ) - # From galaxy.web.form_builder.CheckboxField: - # The hidden field is necessary because if the check box is not checked on the form, it will - # not be included in the request params. The hidden field ensure that this will happen. When - # parsing the request, the value 'true' in the hidden field actually means it is NOT checked. - # See the is_checked() method below. The prefix is necessary in each case to ensure functional - # correctness when the param is inside a conditional. - # - # This may look strange upon initial inspection, but see the comments in the get_html() method - # above for clarification. Basically, if value is not True, then it will always be a list with - # 2 input fields ( a checkbox and a hidden field ) if the checkbox is checked. If it is not - # checked, then value will be only the hidden field. - # - # The create_checkbox_query_string method emulates the described behavior with URL query parameters. - # This is currently necessary because twill does not correctly parse the reselect tool panel section - # form, so the test method has to visit the intended form target "manually". + self.check_for_strings( strings_displayed, strings_not_displayed=[] ) repo_dependencies = self.create_checkbox_query_string( field_name='install_repository_dependencies', value=install_repository_dependencies ) tool_dependencies = self.create_checkbox_query_string( field_name='install_tool_dependencies', value=install_tool_dependencies ) encoded_repository_id = self.security.encode_id( installed_repository.id ) url = '/admin_toolshed/reinstall_repository?id=%s&%s&%s&no_changes=%s&new_tool_panel_section=%s' % \ ( encoded_repository_id, repo_dependencies, tool_dependencies, str( no_changes ), new_tool_panel_section ) self.visit_galaxy_url( url ) - # Then manually initiate the install process, as with installing a repository. See comments in the + # Manually initiate the install process, as with installing a repository. See comments in the # initiate_installation_process method for details. repository_ids = self.initiate_installation_process( install_tool_dependencies, install_repository_dependencies, @@ -639,13 +745,28 @@ 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 = [] + kwd = dict() + if not changeset_revision: + changeset_revision = self.get_repository_tip( repository ) + if user: + review = test_db_util.get_repository_review_by_user_id_changeset_revision( user.id, repository.id, changeset_revision ) + 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=[] ): + 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 + else: + galaxy_url = '' for field_name, search_string in search_fields.items(): - url = '/repository/find_tools' + url = '/repository/find_tools%s' % galaxy_url self.visit_url( url ) tc.fv( "1", "exact_matches", exact_matches ) tc.fv( "1", field_name, search_string ) @@ -746,6 +867,17 @@ found = True break assert found, 'No entry for %s in %s.' % ( data_table, 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. + strings_displayed=[ repository.name, reviewer.username, changeset_revision ] + self.display_reviewed_repositories_owned_by_user( strings_displayed=strings_displayed ) + # Verify that the reviewer has reviewed the specified repository's changeset revision. + strings_displayed=[ repository.name, repository.description, changeset_revision ] + self.display_repository_reviews_by_user( reviewer, strings_displayed=strings_displayed ) + # 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' ]: diff -r 974d7c41b8dfb7e77c6dfa24da05b31d684fd2e6 -r 3a2211dc42f15e0bd357de6abb7dca73221854c7 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 @@ -6,7 +6,7 @@ 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.login( email=common.test_user_1_email, username=common.test_user_1_name ) diff -r 974d7c41b8dfb7e77c6dfa24da05b31d684fd2e6 -r 3a2211dc42f15e0bd357de6abb7dca73221854c7 test/tool_shed/functional/test_0040_repository_circular_dependencies.py --- a/test/tool_shed/functional/test_0040_repository_circular_dependencies.py +++ b/test/tool_shed/functional/test_0040_repository_circular_dependencies.py @@ -10,7 +10,7 @@ filtering_repository_long_description = "Long description of Galaxy's filtering tool" class TestRepositoryCircularDependencies( ShedTwillTestCase ): - '''Verify that the code correctly handles circular dependencies.''' + '''Verify that the code correctly displays repositories with circular repository dependencies.''' def test_0000_initiate_users( self ): """Create necessary user accounts.""" self.logout() diff -r 974d7c41b8dfb7e77c6dfa24da05b31d684fd2e6 -r 3a2211dc42f15e0bd357de6abb7dca73221854c7 test/tool_shed/functional/test_0050_circular_dependencies_4_levels.py --- a/test/tool_shed/functional/test_0050_circular_dependencies_4_levels.py +++ b/test/tool_shed/functional/test_0050_circular_dependencies_4_levels.py @@ -169,6 +169,12 @@ freebayes_repository = test_db_util.get_repository_by_name_and_owner( freebayes_repository_name, common.test_user_1_name ) bismark_repository = test_db_util.get_repository_by_name_and_owner( bismark_repository_name, common.test_user_1_name ) dependency_xml_path = self.generate_temp_path( 'test_0050', additional_paths=[ 'freebayes' ] ) + # convert_chars depends on column_maker + # column_maker depends on convert_chars + # emboss depends on emboss_datatypes + # emboss_datatypes depends on bismark + # freebayes depends on freebayes, emboss, emboss_datatypes, and column_maker + # filtering depends on emboss self.create_repository_dependency( convert_repository, depends_on=[ column_repository ], filepath=dependency_xml_path ) self.create_repository_dependency( column_repository, depends_on=[ convert_repository ], filepath=dependency_xml_path ) self.create_repository_dependency( emboss_datatypes_repository, depends_on=[ bismark_repository ], filepath=dependency_xml_path ) diff -r 974d7c41b8dfb7e77c6dfa24da05b31d684fd2e6 -r 3a2211dc42f15e0bd357de6abb7dca73221854c7 test/tool_shed/functional/test_0060_workflows.py --- a/test/tool_shed/functional/test_0060_workflows.py +++ b/test/tool_shed/functional/test_0060_workflows.py @@ -8,6 +8,7 @@ workflow_name = 'Workflow for 0060_filter_workflow_repository' class TestToolShedWorkflowFeatures( ShedTwillTestCase ): + '''Test valid and invalid workflows.''' def test_0000_initiate_users( self ): """Create necessary user accounts and login as an admin user.""" self.logout() @@ -39,7 +40,8 @@ workflow = file( self.get_filename( 'filtering_workflow/Workflow_for_0060_filter_workflow_repository.ga' ), 'r' ).read() workflow = workflow.replace( '__TEST_TOOL_SHED_URL__', self.url.replace( 'http://', '' ) ) workflow_filepath = self.generate_temp_path( 'test_0060', additional_paths=[ 'filtering_workflow' ] ) - os.makedirs( workflow_filepath ) + if not os.path.exists( workflow_filepath ): + os.makedirs( workflow_filepath ) file( os.path.join( workflow_filepath, workflow_filename ), 'w+' ).write( workflow ) self.upload_file( repository, workflow_filename, diff -r 974d7c41b8dfb7e77c6dfa24da05b31d684fd2e6 -r 3a2211dc42f15e0bd357de6abb7dca73221854c7 test/tool_shed/functional/test_0090_tool_search.py --- /dev/null +++ b/test/tool_shed/functional/test_0090_tool_search.py @@ -0,0 +1,171 @@ +from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os +import tool_shed.base.test_db_util as test_db_util + +emboss_datatypes_repository_name = 'emboss_datatypes_0090' +emboss_datatypes_repository_description = "Datatypes for emboss" +emboss_datatypes_repository_long_description = "Long description of Emboss' datatypes" + +emboss_repository_name = 'emboss_0090' +emboss_repository_description = "Galaxy's emboss tool" +emboss_repository_long_description = "Long description of Galaxy's emboss tool" + +filtering_repository_name = 'filtering_0090' +filtering_repository_description = "Galaxy's filtering tool" +filtering_repository_long_description = "Long description of Galaxy's filtering tool" + +freebayes_repository_name = 'freebayes_0090' +freebayes_repository_description = "Galaxy's freebayes tool" +freebayes_repository_long_description = "Long description of Galaxy's freebayes tool" + +bwa_base_repository_name = 'bwa_base_0090' +bwa_base_repository_description = "BWA Base" +bwa_base_repository_long_description = "NT space mapping with BWA" + +bwa_color_repository_name = 'bwa_color_0090' +bwa_color_repository_description = "BWA Color" +bwa_color_repository_long_description = "Color space mapping with BWA" + +category_name = 'Test 0090 Tool Search And Installation' +category_description = 'Test 0090 Tool Search And Installation' + +class TestRepositoryCircularDependenciesAgain( ShedTwillTestCase ): + '''Test more features related to repository dependencies.''' + 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_bwa_base_repository( self ): + '''Create and populate bwa_base_0090.''' + 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=bwa_base_repository_name, + description=bwa_base_repository_description, + long_description=bwa_base_repository_long_description, + owner=common.test_user_1_name, + category_id=self.security.encode_id( category.id ), + strings_displayed=[] ) + self.upload_file( repository, + 'bwa/bwa_base.tar', + strings_displayed=[], + commit_message='Uploaded bwa_base.tar.' ) + def test_0010_create_bwa_color_repository( self ): + '''Create and populate bwa_color_0090.''' + 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=bwa_color_repository_name, + description=bwa_color_repository_description, + long_description=bwa_color_repository_long_description, + owner=common.test_user_1_name, + category_id=self.security.encode_id( category.id ), + strings_displayed=[] ) + self.upload_file( repository, + 'bwa/bwa_color.tar', + strings_displayed=[], + commit_message='Uploaded bwa_color.tar.' ) + def test_0015_create_emboss_datatypes_repository( self ): + '''Create and populate emboss_datatypes_0090.''' + 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=emboss_datatypes_repository_name, + description=emboss_datatypes_repository_description, + long_description=emboss_datatypes_repository_long_description, + owner=common.test_user_1_name, + category_id=self.security.encode_id( category.id ), + strings_displayed=[] ) + self.upload_file( repository, + 'emboss/datatypes/datatypes_conf.xml', + strings_displayed=[], + commit_message='Uploaded datatypes_conf.xml.' ) + def test_0020_create_emboss_repository( self ): + '''Create and populate emboss_0090.''' + category = self.create_category( name=category_name, description=category_description ) + 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=[] ) + self.upload_file( repository, + 'emboss/emboss.tar', + strings_displayed=[], + commit_message='Uploaded tool tarball.' ) + datatypes_repository = test_db_util.get_repository_by_name_and_owner( emboss_datatypes_repository_name, common.test_user_1_name ) + repository_dependencies_path = self.generate_temp_path( 'test_0090', additional_paths=[ 'emboss' ] ) + self.generate_repository_dependency_xml( [ datatypes_repository ], + self.get_filename( 'repository_dependencies.xml', filepath=repository_dependencies_path ), + dependency_description='Emboss depends on the emboss_datatypes repository.' ) + self.upload_file( repository, + 'repository_dependencies.xml', + filepath=repository_dependencies_path, + commit_message='Uploaded dependency on emboss_datatypes.' ) + def test_0025_create_filtering_repository( self ): + '''Create and populate filtering_0090.''' + category = self.create_category( name=category_name, description=category_description ) + filtering_repository = self.get_or_create_repository( name=filtering_repository_name, + description=filtering_repository_description, + long_description=filtering_repository_long_description, + owner=common.test_user_1_name, + category_id=self.security.encode_id( category.id ), + strings_displayed=[] ) + self.upload_file( filtering_repository, + 'filtering/filtering_1.1.0.tar', + strings_displayed=[], + commit_message='Uploaded filtering.tar.' ) + emboss_repository = test_db_util.get_repository_by_name_and_owner( emboss_repository_name, common.test_user_1_name ) + repository_dependencies_path = self.generate_temp_path( 'test_0090', additional_paths=[ 'filtering' ] ) + self.generate_repository_dependency_xml( [ emboss_repository ], + self.get_filename( 'repository_dependencies.xml', filepath=repository_dependencies_path ), + dependency_description='Filtering depends on the emboss repository.' ) + self.upload_file( filtering_repository, + 'repository_dependencies.xml', + filepath=repository_dependencies_path, + commit_message='Uploaded dependency on emboss.' ) + def test_0030_create_freebayes_repository( self ): + '''Create and populate freebayes_0090.''' + category = self.create_category( name=category_name, description=category_description ) + 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=[] ) + self.upload_file( repository, + 'freebayes/freebayes.tar', + strings_displayed=[], + commit_message='Uploaded freebayes.tar.' ) + def test_0035_create_and_upload_dependency_definitions( self ): + '''Create and upload repository dependency definitions.''' + bwa_color_repository = test_db_util.get_repository_by_name_and_owner( bwa_color_repository_name, common.test_user_1_name ) + bwa_base_repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + emboss_datatypes_repository = test_db_util.get_repository_by_name_and_owner( emboss_datatypes_repository_name, common.test_user_1_name ) + emboss_repository = test_db_util.get_repository_by_name_and_owner( emboss_repository_name, common.test_user_1_name ) + filtering_repository = test_db_util.get_repository_by_name_and_owner( filtering_repository_name, common.test_user_1_name ) + freebayes_repository = test_db_util.get_repository_by_name_and_owner( freebayes_repository_name, common.test_user_1_name ) + dependency_xml_path = self.generate_temp_path( 'test_0090', additional_paths=[ 'freebayes' ] ) + self.create_repository_dependency( emboss_repository, depends_on=[ emboss_datatypes_repository ], filepath=dependency_xml_path ) + self.create_repository_dependency( filtering_repository, depends_on=[ freebayes_repository ], filepath=dependency_xml_path ) + self.create_repository_dependency( bwa_base_repository, depends_on=[ emboss_repository ], filepath=dependency_xml_path ) + self.create_repository_dependency( bwa_color_repository, depends_on=[ filtering_repository ], filepath=dependency_xml_path ) + def test_0040_verify_repository_dependencies( self ): + '''Verify the generated dependency structure.''' + bwa_color_repository = test_db_util.get_repository_by_name_and_owner( bwa_color_repository_name, common.test_user_1_name ) + bwa_base_repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + emboss_datatypes_repository = test_db_util.get_repository_by_name_and_owner( emboss_datatypes_repository_name, common.test_user_1_name ) + emboss_repository = test_db_util.get_repository_by_name_and_owner( emboss_repository_name, common.test_user_1_name ) + filtering_repository = test_db_util.get_repository_by_name_and_owner( filtering_repository_name, common.test_user_1_name ) + freebayes_repository = test_db_util.get_repository_by_name_and_owner( freebayes_repository_name, common.test_user_1_name ) + self.check_repository_dependency( emboss_repository, emboss_datatypes_repository ) + self.check_repository_dependency( filtering_repository, freebayes_repository ) + self.check_repository_dependency( bwa_base_repository, emboss_repository ) + self.check_repository_dependency( bwa_color_repository, filtering_repository ) diff -r 974d7c41b8dfb7e77c6dfa24da05b31d684fd2e6 -r 3a2211dc42f15e0bd357de6abb7dca73221854c7 test/tool_shed/functional/test_0400_repository_component_reviews.py --- /dev/null +++ b/test/tool_shed/functional/test_0400_repository_component_reviews.py @@ -0,0 +1,279 @@ +from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os +import tool_shed.base.test_db_util as test_db_util + +repository_name = 'filtering_0400' +repository_description = 'Galaxy filtering tool for test 0400' +repository_long_description = 'Long description of Galaxy filtering tool for test 0400' + +class TestRepositoryComponentReviews( ShedTwillTestCase ): + '''Test repository component review features.''' + def test_0000_initiate_users( self ): + """Create necessary user accounts and login as an 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' % 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.test_user_2_email, username=common.test_user_2_name ) + test_user_2 = test_db_util.get_user( common.test_user_2_email ) + assert test_user_2 is not None, 'Problem retrieving user with email %s from the database' % common.test_user_2_email + test_user_2_private_role = test_db_util.get_private_role( test_user_2 ) + 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_grant_reviewer_role( self ): + '''Grant the repository reviewer role to test_user_2.''' + reviewer_role = test_db_util.get_role_by_name( 'Repository Reviewer' ) + test_user_2 = test_db_util.get_user( common.test_user_2_email ) + self.grant_role_to_user( test_user_2, reviewer_role ) + def test_0010_verify_repository_review_components( self ): + '''Ensure that the required review components exist.''' + strings_not_displayed=[ 'Repository dependencies' ] + self.manage_review_components( strings_not_displayed=strings_not_displayed ) + self.add_repository_review_component( name='Repository dependencies', + description='Repository dependencies defined in a file named repository_dependencies.xml included in the repository' ) + strings_displayed=[ 'Data types', 'Functional tests', 'README', 'Repository dependencies', 'Tool dependencies', 'Tools', 'Workflows' ] + self.manage_review_components( strings_displayed=strings_displayed ) + def test_0015_create_repository( self ): + """Create and populate the filtering repository""" + category = self.create_category( name='Test 0400 Repository Component Reviews', description='Test 0400 Repository Component Reviews' ) + self.logout() + self.login( email=common.test_user_1_email, username=common.test_user_1_name ) + strings_displayed = [ 'Repository %s' % "'%s'" % repository_name, + 'Repository %s has been created' % "'%s'" % repository_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 ), + strings_displayed=strings_displayed ) + self.upload_file( repository, 'filtering/filtering_1.1.0.tar', commit_message="Uploaded filtering 1.1.0" ) + def test_0020_review_initial_revision_data_types( self ): + '''Review the datatypes component for the current tip revision.''' + # Review this revision: + # Data types (N/A) + # Functional tests (One star, comment 'functional tests missing') + # README (N/A) + # Repository dependencies (N/A) + # Tool dependencies (N/A) + # Tools (5 stars, good review) + # Workflows (N/A) + self.logout() + self.login( email=common.test_user_2_email, username=common.test_user_2_name ) + repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) + review_contents_dict = { 'Data types': dict() } + self.create_repository_review( repository, review_contents_dict ) + def test_0025_verify_datatype_review( self ): + '''Verify that the datatypes component review displays correctly.''' + 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 ) + user = test_db_util.get_user( common.test_user_2_email ) + strings_displayed = [ 'Data types', 'not_applicable' ] + strings_not_displayed = [ 'Functional tests', 'README', 'Repository dependencies', 'Tool dependencies', 'Tools', 'Workflows' ] + self.verify_repository_reviews( repository, reviewer=user, strings_displayed=strings_displayed ) + def test_0030_review_initial_revision_functional_tests( self ): + '''Review the datatypes component for the current tip revision.''' + self.logout() + self.login( email=common.test_user_2_email, username=common.test_user_2_name ) + repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) + user = test_db_util.get_user( common.test_user_2_email ) + review_contents_dict = { 'Functional tests': dict( rating=1, comment='Functional tests missing', approved='no', private='yes' ) } + self.review_repository( repository, review_contents_dict, user ) +# def test_0030_verify_review_display( self ): +# '''Verify that private reviews are restricted to owner and reviewer, and non-private views are viewable by others.''' +# # Currently not implemented because third parties cannot view reviews whether they are private or not. +# self.logout() +# self.login( email=common.test_user_3_email, username=common.test_user_3_name ) + def test_0035_verify_functional_test_review( self ): + '''Verify that the datatypes component review displays correctly.''' + 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 ) + user = test_db_util.get_user( common.test_user_2_email ) + strings_displayed=[ 'Functional tests', 'Functional tests missing', 'no' ] + strings_not_displayed = [ 'README', 'Repository dependencies', 'Tool dependencies', 'Tools', 'Workflows' ] + self.verify_repository_reviews( repository, reviewer=user, strings_displayed=strings_displayed ) + def test_0040_review_readme( self ): + '''Review the readme component for the current tip revision.''' + self.logout() + self.login( email=common.test_user_2_email, username=common.test_user_2_name ) + repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) + user = test_db_util.get_user( common.test_user_2_email ) + review_contents_dict = { 'README': dict() } + self.review_repository( repository, review_contents_dict, user ) + def test_0045_verify_readme_review( self ): + '''Verify that the datatypes component review displays correctly.''' + 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 ) + user = test_db_util.get_user( common.test_user_2_email ) + strings_displayed=[ 'README', 'not_applicable' ] + strings_not_displayed = [ 'Repository dependencies', 'Tool dependencies', 'Tools', 'Workflows' ] + self.verify_repository_reviews( repository, reviewer=user, strings_displayed=strings_displayed ) + def test_0050_review_repository_dependencies( self ): + '''Review the repository dependencies component for the current tip revision.''' + self.logout() + self.login( email=common.test_user_2_email, username=common.test_user_2_name ) + repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) + user = test_db_util.get_user( common.test_user_2_email ) + review_contents_dict = { 'Repository dependencies': dict() } + self.review_repository( repository, review_contents_dict, user ) + def test_0055_verify_repository_dependency_review( self ): + '''Verify that the datatypes component review displays correctly.''' + 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 ) + user = test_db_util.get_user( common.test_user_2_email ) + strings_displayed=[ 'Repository dependencies', 'not_applicable' ] + strings_not_displayed = [ 'Tool dependencies', 'Tools', 'Workflows' ] + self.verify_repository_reviews( repository, reviewer=user, strings_displayed=strings_displayed ) + def test_0060_review_tool_dependencies( self ): + '''Review the tool dependencies component for the current tip revision.''' + self.logout() + self.login( email=common.test_user_2_email, username=common.test_user_2_name ) + repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) + user = test_db_util.get_user( common.test_user_2_email ) + review_contents_dict = { 'Tool dependencies': dict() } + self.review_repository( repository, review_contents_dict, user ) + def test_0065_verify_tool_dependency_review( self ): + '''Verify that the datatypes component review displays correctly.''' + 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 ) + user = test_db_util.get_user( common.test_user_2_email ) + strings_displayed=[ 'Tool dependencies', 'not_applicable' ] + strings_not_displayed = [ 'Tools', 'Workflows' ] + self.verify_repository_reviews( repository, reviewer=user, strings_displayed=strings_displayed ) + def test_0070_review_tools( self ): + '''Review the tools component for the current tip revision.''' + self.logout() + self.login( email=common.test_user_2_email, username=common.test_user_2_name ) + repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) + user = test_db_util.get_user( common.test_user_2_email ) + review_contents_dict = { 'Tools': dict( rating=5, comment='Excellent tool, easy to use.', approved='yes', private='no' ) } + self.review_repository( repository, review_contents_dict, test_db_util.get_user( common.test_user_2_email ) ) + def test_0075_verify_tools_review( self ): + '''Verify that the datatypes component review displays correctly.''' + 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 ) + user = test_db_util.get_user( common.test_user_2_email ) + strings_displayed=[ 'Tools', 'yes', 'Excellent tool, easy to use.' ] + strings_not_displayed = [ 'Workflows' ] + self.verify_repository_reviews( repository, reviewer=user, strings_displayed=strings_displayed ) + def test_0080_review_workflows( self ): + '''Review the workflows component for the current tip revision.''' + self.logout() + self.login( email=common.test_user_2_email, username=common.test_user_2_name ) + repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) + user = test_db_util.get_user( common.test_user_2_email ) + review_contents_dict = { 'Workflows': dict() } + self.review_repository( repository, review_contents_dict, user ) + def test_0085_verify_workflows_review( self ): + '''Verify that the datatypes component review displays correctly.''' + 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 ) + user = test_db_util.get_user( common.test_user_2_email ) + strings_displayed=[ 'Workflows', 'not_applicable' ] + self.verify_repository_reviews( repository, reviewer=user, strings_displayed=strings_displayed ) + def test_0090_upload_readme_file( self ): + '''Upload a readme file to the filtering repository.''' + 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 ) + user = test_db_util.get_user( common.test_user_2_email ) + self.upload_file( repository, 'readme.txt', commit_message="Uploaded readme.txt" ) + def test_0095_review_new_changeset_readme_component( self ): + '''Update the filtering repository's readme component review to reflect the presence of the readme file.''' + self.logout() + self.login( email=common.test_user_2_email, username=common.test_user_2_name ) + repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) + user = test_db_util.get_user( common.test_user_2_email ) + # Get the changeset immediately prior to the tip, and pass it to the create review method. + changelog = self.get_repository_changelog( repository ) + changeset_revision, ctx_revision = changelog[-2] + previous_review = test_db_util.get_repository_review_by_user_id_changeset_revision( user.id, repository.id, str( changeset_revision ) ) + review_contents_dict = { 'README': dict( rating=5, comment='Clear and concise readme file, a true pleasure to read.', approved='yes', private='no' ) } + self.create_repository_review( repository, + review_contents_dict, + changeset_revision=self.get_repository_tip( repository ), + copy_from=( str( changeset_revision ), previous_review.id ) ) + def test_0100_verify_readme_review( self ): + '''Verify that the readme component review displays correctly.''' + 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 ) + user = test_db_util.get_user( common.test_user_2_email ) + strings_displayed = [ 'README', 'yes', 'Clear and concise readme file, a true pleasure to read.' ] + self.verify_repository_reviews( repository, reviewer=user, strings_displayed=strings_displayed ) + def test_0105_upload_test_data( self ): + '''Upload the missing test data to the filtering repository.''' + 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 ) + user = test_db_util.get_user( common.test_user_2_email ) + self.upload_file( repository, 'filtering/filtering_test_data.tar', commit_message="Uploaded test data." ) + def test_0110_review_new_changeset_functional_tests( self ): + '''Update the filtering repository's readme component review to reflect the presence of the readme file.''' + self.logout() + self.login( email=common.test_user_2_email, username=common.test_user_2_name ) + repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) + user = test_db_util.get_user( common.test_user_2_email ) + # Get the changeset immediately prior to the tip, and pass it to the create review method. + changelog = self.get_repository_changelog( repository ) + changeset_revision, ctx_revision = changelog[-2] + previous_review = test_db_util.get_repository_review_by_user_id_changeset_revision( user.id, repository.id, str( changeset_revision ) ) + review_contents_dict = { 'Functional tests': dict( rating=5, comment='A good set of functional tests.', approved='yes', private='no' ) } + self.create_repository_review( repository, + review_contents_dict, + changeset_revision=self.get_repository_tip( repository ), + copy_from=( str( changeset_revision ), previous_review.id ) ) + def test_0115_verify_functional_tests_review( self ): + '''Verify that the functional tests component review displays correctly.''' + 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 ) + user = test_db_util.get_user( common.test_user_2_email ) + strings_displayed=[ 'Functional tests', 'yes', 'A good set of functional tests.' ] + self.verify_repository_reviews( repository, reviewer=user, strings_displayed=strings_displayed ) + def test_0120_upload_new_tool_version( self ): + '''Upload filtering 2.2.0 to the filtering repository.''' + 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 ) + user = test_db_util.get_user( common.test_user_2_email ) + self.upload_file( repository, + 'filtering/filtering_2.2.0.tar', + commit_message="Uploaded filtering 2.2.0", + remove_repo_files_not_in_tar='No' ) + def test_0125_review_new_changeset_functional_tests( self ): + '''Update the filtering repository's review to apply to the new changeset with filtering 2.2.0.''' + self.logout() + self.login( email=common.test_user_2_email, username=common.test_user_2_name ) + repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) + user = test_db_util.get_user( common.test_user_2_email ) + # Get the changeset immediately prior to the tip, and pass it to the create review method. + changelog = self.get_repository_changelog( repository ) + changeset_revision, ctx_revision = changelog[-2] + previous_review = test_db_util.get_repository_review_by_user_id_changeset_revision( user.id, repository.id, str( changeset_revision ) ) + # Something needs to change so that the review will save. + review_contents_dict = { 'Tools': dict( rating=5, comment='Version 2.2.0 does the impossible and improves this tool.', approved='yes', private='yes' ) } + self.create_repository_review( repository, + review_contents_dict, + changeset_revision=self.get_repository_tip( repository ), + copy_from=( str( changeset_revision ), previous_review.id ) ) + def test_0135_verify_review_for_new_version( self ): + '''Verify that the reviews display correctly for this changeset 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 ) + user = test_db_util.get_user( common.test_user_2_email ) + strings_displayed = [ 'Data types', 'Functional tests', 'yes', 'A good set of functional tests.', 'README', 'yes', 'Workflows', 'Tools' ] + strings_displayed.extend( [ 'Clear and concise readme file, a true pleasure to read.', 'Tool dependencies', 'not_applicable' ] ) + strings_displayed.extend( [ 'Repository dependencies', 'Version 2.2.0 does the impossible and improves this tool.' ] ) + self.verify_repository_reviews( repository, reviewer=user, strings_displayed=strings_displayed ) diff -r 974d7c41b8dfb7e77c6dfa24da05b31d684fd2e6 -r 3a2211dc42f15e0bd357de6abb7dca73221854c7 test/tool_shed/functional/test_1050_circular_dependencies_4_levels.py --- a/test/tool_shed/functional/test_1050_circular_dependencies_4_levels.py +++ b/test/tool_shed/functional/test_1050_circular_dependencies_4_levels.py @@ -163,6 +163,12 @@ freebayes_repository = test_db_util.get_repository_by_name_and_owner( freebayes_repository_name, common.test_user_1_name ) bismark_repository = test_db_util.get_repository_by_name_and_owner( bismark_repository_name, common.test_user_1_name ) dependency_xml_path = self.generate_temp_path( 'test_1050', additional_paths=[ 'dependencies' ] ) + # convert_chars depends on column_maker + # column_maker depends on convert_chars + # emboss depends on emboss_datatypes + # emboss_datatypes depends on bismark + # freebayes depends on freebayes, emboss, emboss_datatypes, and column_maker + # filtering depends on emboss self.create_repository_dependency( convert_repository, depends_on=[ column_repository ], filepath=dependency_xml_path ) self.create_repository_dependency( column_repository, depends_on=[ convert_repository ], filepath=dependency_xml_path ) self.create_repository_dependency( emboss_datatypes_repository, depends_on=[ bismark_repository ], filepath=dependency_xml_path ) @@ -224,6 +230,7 @@ install_tool_dependencies=False, install_repository_dependencies=True, new_tool_panel_section='column_maker' ) + # This should result in column_maker and convert_chars being installed, and the rest never installed. installed_repositories = [ ( column_repository_name, common.test_user_1_name ), ( convert_repository_name, common.test_user_1_name ) ] uninstalled_repositories = [ ( emboss_datatypes_repository_name, common.test_user_1_name ), @@ -244,6 +251,7 @@ new_tool_panel_section='emboss_5_0050' ) if running_standalone: assert original_datatypes < self.get_datatypes_count(), 'Installing a repository that depends on emboss_datatypes did not add datatypes.' + # Now we have emboss_datatypes, emboss, bismark, column_maker, and convert_chars installed, filtering and freebayes never installed. installed_repositories = [ ( emboss_datatypes_repository_name, common.test_user_1_name ), ( column_repository_name, common.test_user_1_name ), ( emboss_repository_name, common.test_user_1_name ), @@ -258,6 +266,7 @@ repository = test_db_util.get_installed_repository_by_name_owner( emboss_datatypes_repository_name, common.test_user_1_name ) self.uninstall_repository( repository, remove_from_disk=False ) assert original_datatypes > self.get_datatypes_count(), 'Deactivating emboss_datatypes did not remove datatypes.' + # Now we have emboss, bismark, column_maker, and convert_chars installed, filtering and freebayes never installed, and emboss_datatypes deactivated. installed_repositories = [ ( column_repository_name, common.test_user_1_name ), ( emboss_repository_name, common.test_user_1_name ), ( convert_repository_name, common.test_user_1_name ), @@ -276,6 +285,8 @@ self.display_galaxy_browse_repositories_page( strings_not_displayed=strings_not_displayed ) test_db_util.ga_refresh( repository ) self.check_galaxy_repository_tool_panel_section( repository, 'emboss_5_0050' ) + # Now we have bismark, column_maker, and convert_chars installed, filtering and freebayes never installed, emboss_datatypes deactivated, + # and emboss uninstalled. installed_repositories = [ ( column_repository_name, common.test_user_1_name ), ( convert_repository_name, common.test_user_1_name ), ( bismark_repository_name, common.test_user_1_name ) ] @@ -303,6 +314,8 @@ datatypes_repository.name, datatypes_repository.installed_changeset_revision ] self.display_galaxy_browse_repositories_page( strings_displayed=strings_displayed ) + # Installing freebayes should automatically reinstall emboss and reactivate emboss_datatypes. + # Now column_maker, convert_chars, emboss, emboss_datatypes, freebayes, and bismark should be installed. installed_repositories = [ ( column_repository_name, common.test_user_1_name ), ( emboss_datatypes_repository_name, common.test_user_1_name ), ( emboss_repository_name, common.test_user_1_name ), diff -r 974d7c41b8dfb7e77c6dfa24da05b31d684fd2e6 -r 3a2211dc42f15e0bd357de6abb7dca73221854c7 test/tool_shed/functional/test_1070_invalid_tool.py --- a/test/tool_shed/functional/test_1070_invalid_tool.py +++ b/test/tool_shed/functional/test_1070_invalid_tool.py @@ -7,7 +7,7 @@ category_name = 'Test 0070 Invalid Tool Revisions' class TestFreebayesRepository( ShedTwillTestCase ): - '''Testing freebayes with tool data table entries, .loc files, and tool dependencies.''' + '''Test repository with multiple revisions with invalid tools.''' def test_0000_create_or_login_admin_user( self ): """Create necessary user accounts and login as an admin user.""" self.galaxy_logout() diff -r 974d7c41b8dfb7e77c6dfa24da05b31d684fd2e6 -r 3a2211dc42f15e0bd357de6abb7dca73221854c7 test/tool_shed/functional/test_1080_advanced_circular_dependency_installation.py --- a/test/tool_shed/functional/test_1080_advanced_circular_dependency_installation.py +++ b/test/tool_shed/functional/test_1080_advanced_circular_dependency_installation.py @@ -17,7 +17,7 @@ running_standalone = False class TestRepositoryDependencies( ShedTwillTestCase ): - '''Testing freebayes with tool data table entries, .loc files, and tool dependencies.''' + '''Testing uninstalling and reinstalling repository dependencies, and setting tool panel sections.''' def test_0000_create_or_login_admin_user( self ): """Create necessary user accounts and login as an admin user.""" self.galaxy_logout() diff -r 974d7c41b8dfb7e77c6dfa24da05b31d684fd2e6 -r 3a2211dc42f15e0bd357de6abb7dca73221854c7 test/tool_shed/functional/test_1085_repository_dependency_handling.py --- a/test/tool_shed/functional/test_1085_repository_dependency_handling.py +++ b/test/tool_shed/functional/test_1085_repository_dependency_handling.py @@ -15,7 +15,7 @@ log = logging.getLogger( __name__ ) class TestRepositoryDependencies( ShedTwillTestCase ): - '''Testing freebayes with tool data table entries, .loc files, and tool dependencies.''' + '''Testing the behavior of repository dependencies with tool panel sections.''' def test_0000_create_or_login_admin_user( self ): """Create necessary user accounts and login as an admin user.""" self.galaxy_logout() diff -r 974d7c41b8dfb7e77c6dfa24da05b31d684fd2e6 -r 3a2211dc42f15e0bd357de6abb7dca73221854c7 test/tool_shed/functional/test_1090_install_tool_from_tool_search.py --- /dev/null +++ b/test/tool_shed/functional/test_1090_install_tool_from_tool_search.py @@ -0,0 +1,266 @@ +from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os +import tool_shed.base.test_db_util as test_db_util + +emboss_datatypes_repository_name = 'emboss_datatypes_0090' +emboss_datatypes_repository_description = "Datatypes for emboss" +emboss_datatypes_repository_long_description = "Long description of Emboss' datatypes" + +emboss_repository_name = 'emboss_0090' +emboss_repository_description = "Galaxy's emboss tool" +emboss_repository_long_description = "Long description of Galaxy's emboss tool" + +filtering_repository_name = 'filtering_0090' +filtering_repository_description = "Galaxy's filtering tool" +filtering_repository_long_description = "Long description of Galaxy's filtering tool" + +freebayes_repository_name = 'freebayes_0090' +freebayes_repository_description = "Galaxy's freebayes tool" +freebayes_repository_long_description = "Long description of Galaxy's freebayes tool" + +bwa_base_repository_name = 'bwa_base_0090' +bwa_base_repository_description = "BWA Base" +bwa_base_repository_long_description = "NT space mapping with BWA" + +bwa_color_repository_name = 'bwa_color_0090' +bwa_color_repository_description = "BWA Color" +bwa_color_repository_long_description = "Color space mapping with BWA" + +category_name = 'Test 0090 Tool Search And Installation' +category_description = 'Test 0090 Tool Search And Installation' + +running_standalone = False + +class TestToolSearchAndInstall( ShedTwillTestCase ): + '''Verify that the code correctly handles circular dependencies down to n levels.''' + 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_bwa_base_repository( self ): + '''Create and populate bwa_base_0090.''' + 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 ) + global running_standalone + repository = self.get_or_create_repository( name=bwa_base_repository_name, + description=bwa_base_repository_description, + long_description=bwa_base_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 ): + running_standalone = True + self.upload_file( repository, + 'bwa/bwa_base.tar', + strings_displayed=[], + commit_message='Uploaded bwa_base.tar.' ) + def test_0010_create_bwa_color_repository( self ): + '''Create and populate bwa_color_0090.''' + category = self.create_category( name=category_name, description=category_description ) + global running_standalone + repository = self.get_or_create_repository( name=bwa_color_repository_name, + description=bwa_color_repository_description, + long_description=bwa_color_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 ): + running_standalone = True + self.upload_file( repository, + 'bwa/bwa_color.tar', + strings_displayed=[], + commit_message='Uploaded bwa_color.tar.' ) + def test_0015_create_emboss_datatypes_repository( self ): + '''Create and populate emboss_datatypes_0090.''' + category = self.create_category( name=category_name, description=category_description ) + global running_standalone + repository = self.get_or_create_repository( name=emboss_datatypes_repository_name, + description=emboss_datatypes_repository_description, + long_description=emboss_datatypes_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 ): + running_standalone = True + self.upload_file( repository, + 'emboss/datatypes/datatypes_conf.xml', + strings_displayed=[], + commit_message='Uploaded datatypes_conf.xml.' ) + def test_0020_create_emboss_repository( self ): + '''Create and populate emboss_0090.''' + category = self.create_category( name=category_name, description=category_description ) + global running_standalone + 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=[] ) + if self.repository_is_new( repository ): + running_standalone = True + self.upload_file( repository, + 'emboss/emboss.tar', + strings_displayed=[], + commit_message='Uploaded tool tarball.' ) + def test_0025_create_filtering_repository( self ): + '''Create and populate filtering_0090.''' + category = self.create_category( name=category_name, description=category_description ) + global running_standalone + repository = self.get_or_create_repository( name=filtering_repository_name, + description=filtering_repository_description, + long_description=filtering_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 ): + running_standalone = True + self.upload_file( repository, + 'filtering/filtering_1.1.0.tar', + strings_displayed=[], + commit_message='Uploaded filtering.tar.' ) + def test_0030_create_freebayes_repository( self ): + '''Create and populate freebayes_0090.''' + category = self.create_category( name=category_name, description=category_description ) + global running_standalone + 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=[] ) + if self.repository_is_new( repository ): + running_standalone = True + self.upload_file( repository, + 'freebayes/freebayes.tar', + strings_displayed=[], + commit_message='Uploaded freebayes.tar.' ) + def test_0035_create_and_upload_dependency_definitions( self ): + '''Create and upload repository dependency definitions.''' + global running_standalone + if running_standalone: + bwa_color_repository = test_db_util.get_repository_by_name_and_owner( bwa_color_repository_name, common.test_user_1_name ) + bwa_base_repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + emboss_datatypes_repository = test_db_util.get_repository_by_name_and_owner( emboss_datatypes_repository_name, common.test_user_1_name ) + emboss_repository = test_db_util.get_repository_by_name_and_owner( emboss_repository_name, common.test_user_1_name ) + filtering_repository = test_db_util.get_repository_by_name_and_owner( filtering_repository_name, common.test_user_1_name ) + freebayes_repository = test_db_util.get_repository_by_name_and_owner( freebayes_repository_name, common.test_user_1_name ) + dependency_xml_path = self.generate_temp_path( 'test_0090', additional_paths=[ 'freebayes' ] ) + self.create_repository_dependency( emboss_repository, depends_on=[ emboss_datatypes_repository ], filepath=dependency_xml_path ) + self.create_repository_dependency( filtering_repository, depends_on=[ freebayes_repository ], filepath=dependency_xml_path ) + self.create_repository_dependency( bwa_base_repository, depends_on=[ emboss_repository ], filepath=dependency_xml_path ) + self.create_repository_dependency( bwa_color_repository, depends_on=[ filtering_repository ], filepath=dependency_xml_path ) + def test_0040_verify_repository_dependencies( self ): + '''Verify the generated dependency structure.''' + bwa_color_repository = test_db_util.get_repository_by_name_and_owner( bwa_color_repository_name, common.test_user_1_name ) + bwa_base_repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + emboss_datatypes_repository = test_db_util.get_repository_by_name_and_owner( emboss_datatypes_repository_name, common.test_user_1_name ) + emboss_repository = test_db_util.get_repository_by_name_and_owner( emboss_repository_name, common.test_user_1_name ) + filtering_repository = test_db_util.get_repository_by_name_and_owner( filtering_repository_name, common.test_user_1_name ) + freebayes_repository = test_db_util.get_repository_by_name_and_owner( freebayes_repository_name, common.test_user_1_name ) + self.check_repository_dependency( emboss_repository, emboss_datatypes_repository ) + self.check_repository_dependency( filtering_repository, freebayes_repository ) + self.check_repository_dependency( bwa_base_repository, emboss_repository ) + self.check_repository_dependency( bwa_color_repository, filtering_repository ) + def test_0045_install_freebayes_repository( self ): + '''Install freebayes without repository dependencies.''' + self.galaxy_logout() + self.galaxy_login( email=common.admin_email, username=common.admin_username ) + # After this test, the repositories should be in the following states: + # Installed: freebayes + # Never installed: filtering, emboss, emboss_datatypes, bwa_color, bwa_base + self.install_repository( freebayes_repository_name, + common.test_user_1_name, + category_name, + install_tool_dependencies=False, + install_repository_dependencies=False, + new_tool_panel_section='freebayes_1090' ) + installed_repositories = [ ( freebayes_repository_name, common.test_user_1_name ) ] + uninstalled_repositories = [ ( filtering_repository_name, common.test_user_1_name ), + ( emboss_repository_name, common.test_user_1_name ), + ( emboss_datatypes_repository_name, common.test_user_1_name ), + ( bwa_color_repository_name, common.test_user_1_name ), + ( bwa_base_repository_name, common.test_user_1_name ) ] + self.verify_installed_uninstalled_repositories( installed_repositories=installed_repositories, uninstalled_repositories=uninstalled_repositories ) + def test_0050_install_deactivate_filtering_repository( self ): + '''Install and deactivate filtering.''' + global running_standalone + original_datatypes = self.get_datatypes_count() + # After this test, the repositories should be in the following states: + # Installed: freebayes + # Deactivated: filtering + # Never installed: emboss, emboss_datatypes, bwa_color, bwa_base + self.install_repository( filtering_repository_name, + common.test_user_1_name, + category_name, + install_tool_dependencies=False, + install_repository_dependencies=False, + new_tool_panel_section='filtering_1090' ) + installed_repositories = [ ( filtering_repository_name, common.test_user_1_name ), + ( freebayes_repository_name, common.test_user_1_name ) ] + uninstalled_repositories = [ ( emboss_repository_name, common.test_user_1_name ), + ( emboss_datatypes_repository_name, common.test_user_1_name ), + ( bwa_color_repository_name, common.test_user_1_name ), + ( bwa_base_repository_name, common.test_user_1_name ) ] + self.verify_installed_uninstalled_repositories( installed_repositories=installed_repositories, uninstalled_repositories=uninstalled_repositories ) + filtering_repository = test_db_util.get_installed_repository_by_name_owner( filtering_repository_name, common.test_user_1_name ) + self.uninstall_repository( filtering_repository, remove_from_disk=False ) + def test_0055_install_uninstall_datatypes_repository( self ): + '''Install and uninstall emboss_datatypes.''' + # After this test, the repositories should be in the following states: + # Installed: freebayes + # Deactivated: filtering + # Uninstalled: emboss_datatypes + # Never installed: emboss, bwa_color, bwa_base + self.install_repository( emboss_datatypes_repository_name, + common.test_user_1_name, + category_name, + includes_tools=False ) + installed_repositories = [ ( emboss_datatypes_repository_name, common.test_user_1_name ), + ( freebayes_repository_name, common.test_user_1_name ) ] + uninstalled_repositories = [ ( emboss_repository_name, common.test_user_1_name ), + ( filtering_repository_name, common.test_user_1_name ), + ( bwa_color_repository_name, common.test_user_1_name ), + ( bwa_base_repository_name, common.test_user_1_name ) ] + self.verify_installed_uninstalled_repositories( installed_repositories=installed_repositories, uninstalled_repositories=uninstalled_repositories ) + datatypes_repository = test_db_util.get_installed_repository_by_name_owner( emboss_datatypes_repository_name, common.test_user_1_name ) + self.uninstall_repository( datatypes_repository, remove_from_disk=True ) + def test_0060_search_for_bwa_tools( self ): + '''Search for and install the repositories with BWA tools, and verify that this reinstalls emboss_datatypes and reactivates filtering.''' + bwa_color_repository = test_db_util.get_repository_by_name_and_owner( bwa_color_repository_name, common.test_user_1_name ) + bwa_base_repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + bwa_base_revision = self.get_repository_tip( bwa_base_repository ) + bwa_color_revision = self.get_repository_tip( bwa_color_repository ) + self.search_for_valid_tools( search_fields={ 'tool_id': 'bwa' }, + exact_matches=False, from_galaxy=True, + strings_displayed=[ bwa_color_repository_name, bwa_base_repository_name, bwa_base_revision, bwa_color_revision ] ) + strings_displayed=[ freebayes_repository_name, emboss_repository_name, filtering_repository_name ] + strings_displayed.extend( [ bwa_color_repository_name, bwa_base_repository_name, emboss_datatypes_repository_name ] ) + strings_displayed.extend( [ 'bwa', 'Handle', 'tool dependencies' ] ) + repositories_to_install = [ bwa_color_repository, bwa_base_repository ] + # BWA is a good candidate for testing the installation of tool dependencies, but it is a core requirement of functional + # tests that they be able to run independently of any network connection or remote data. + # + # After this test, the repositories should be in the following state: + # Installed: bwa_color, bwa_base, emboss_datatypes, emboss, filtering, freebayes + self.install_repositories_from_search_results( repositories_to_install, + install_repository_dependencies='True', + install_tool_dependencies=False, + new_tool_panel_section='bwa_1090', + strings_displayed=strings_displayed ) + + installed_repositories = [ ( emboss_repository_name, common.test_user_1_name ), + ( filtering_repository_name, common.test_user_1_name ), + ( bwa_color_repository_name, common.test_user_1_name ), + ( bwa_base_repository_name, common.test_user_1_name ), + ( emboss_datatypes_repository_name, common.test_user_1_name ), + ( freebayes_repository_name, common.test_user_1_name ) ] + uninstalled_repositories = [] + self.verify_installed_uninstalled_repositories( installed_repositories=installed_repositories, uninstalled_repositories=uninstalled_repositories ) diff -r 974d7c41b8dfb7e77c6dfa24da05b31d684fd2e6 -r 3a2211dc42f15e0bd357de6abb7dca73221854c7 test/tool_shed/test_data/bwa/bwa_base.tar Binary file test/tool_shed/test_data/bwa/bwa_base.tar has changed diff -r 974d7c41b8dfb7e77c6dfa24da05b31d684fd2e6 -r 3a2211dc42f15e0bd357de6abb7dca73221854c7 test/tool_shed/test_data/bwa/bwa_color.tar Binary file test/tool_shed/test_data/bwa/bwa_color.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.