1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/7bf8f6a1da9c/ changeset: 7bf8f6a1da9c user: inithello date: 2013-02-13 16:58:10 summary: Tool shed functional test enhancements and documentation. affected #: 3 files diff -r 3eff396a81d833a2dcabce2fd34b53badf707984 -r 7bf8f6a1da9c7d6148712e574f16a34a2c6e1525 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 @@ -1,9 +1,11 @@ -import galaxy.model +import galaxy.model, logging import galaxy.webapps.community.model as model from galaxy.model.orm import * from galaxy.webapps.community.model.mapping import context as sa_session from galaxy.model.mapping import context as ga_session +log = logging.getLogger( 'test.tool_shed.test_db_util' ) + def delete_obj( obj ): sa_session.delete( obj ) sa_session.flush() @@ -57,10 +59,44 @@ 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 ) \ + .filter( and_( model.RepositoryReview.table.c.repository_id == repository_id, + model.RepositoryReview.table.c.deleted == False, + model.RepositoryReview.table.c.changeset_revision == changeset_revision, + model.RepositoryReview.table.c.user_id == reviewer_user_id ) ) \ + .all() + elif reviewer_user_id: + reviews = sa_session.query( model.RepositoryReview ) \ + .filter( and_( model.RepositoryReview.table.c.repository_id == repository_id, + model.RepositoryReview.table.c.deleted == False, + model.RepositoryReview.table.c.user_id == reviewer_user_id ) ) \ + .all() + else: + reviews = sa_session.query( model.RepositoryReview ) \ + .filter( and_( model.RepositoryReview.table.c.repository_id == repository_id, + 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 = [] + for ctx_rev, changeset_hash in changelog_tuples: + for review in reviews: + 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_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, diff -r 3eff396a81d833a2dcabce2fd34b53badf707984 -r 7bf8f6a1da9c7d6148712e574f16a34a2c6e1525 test/tool_shed/base/twilltestcase.py --- a/test/tool_shed/base/twilltestcase.py +++ b/test/tool_shed/base/twilltestcase.py @@ -493,6 +493,14 @@ 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 ) + if reviews: + last_review = reviews[ -1 ] + 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: @@ -508,9 +516,13 @@ 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( self, repository ): + def get_repository_changelog_tuples( self, repository ): repo = hg.repository( ui.ui(), self.get_repo_path( repository ) ) - return [ ( repo.changectx( changeset ), changeset ) for changeset in repo.changelog ] + changelog_tuples = [] + for changeset in repo.changelog: + 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: diff -r 3eff396a81d833a2dcabce2fd34b53badf707984 -r 7bf8f6a1da9c7d6148712e574f16a34a2c6e1525 test/tool_shed/functional/test_0400_repository_component_reviews.py --- a/test/tool_shed/functional/test_0400_repository_component_reviews.py +++ b/test/tool_shed/functional/test_0400_repository_component_reviews.py @@ -5,10 +5,45 @@ repository_description = 'Galaxy filtering tool for test 0400' repository_long_description = 'Long description of Galaxy filtering tool for test 0400' +''' +1. Create users. +2. Grant reviewer role to test_user_2. +3. Check that the review components that are to be tested are defined in this tool shed instance. +4. Create a repository, owned by test_user_1, to be reviewed by test_user_2. +5. Review the datatypes component on the repository. +6. Check that no other components besides datatypes display as reviewed. +7. Review the functional tests component on the repository. +8. Check that only functional tests and datatypes display as reviewed. +9. Review the readme component on the repository. +10. Check that only functional tests, datatypes, and readme display as reviewed. +11. Review the repository dependencies component. +12. Check that only repository dependencies, functional tests, datatypes, and readme display as reviewed. +13. Review the tool dependencies component. +14. Check that only tool dependencies, repository dependencies, functional tests, datatypes, and readme display as reviewed. +15. Review the tools component. +16. Check that only tools, tool dependencies, repository dependencies, functional tests, datatypes, and readme display as reviewed. +17. Review the workflows component. +18. Check that all components display as reviewed. +19. Upload readme.txt to the repository. +20. Copy the previous review, and update the readme component review to reflect the existence of a readme file. +21. Check that the readme component review has been updated, and the other component reviews are present. +22. Upload test data to the repository. This will also create a new changeset revision. +23. Review the functional tests component on the repository, copying the other components from the previous review. +24. Verify that the functional tests component review has been updated, and as in step 21, the other reviews are unchanged. +25. Upload a new version of the tool. +26. Review the new revision's functional tests component. +27. Verify that the functional tests component review displays correctly. +''' + class TestRepositoryComponentReviews( ShedTwillTestCase ): '''Test repository component review features.''' def test_0000_initiate_users( self ): """Create necessary user accounts and login as an admin user.""" + """ + We are at step 1. + Create all the user accounts that are needed for this test script to run independently of other test. + 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 ) @@ -26,11 +61,21 @@ 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.''' + """ + We are at step 2. + We now have an admin user (admin_user) and two non-admin users (test_user_1 and test_user_2). Grant the repository + reviewer role to test_user_2, who will not be the owner of the reviewed repositories. + """ 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.''' + """ + We are at step 3. + We now have an admin user (admin_user) and two non-admin users (test_user_1 and test_user_2). Grant the repository + reviewer role to test_user_2, who will not be the owner of the reviewed repositories. + """ strings_not_displayed=[ 'Repository dependencies' ] self.manage_review_components( strings_not_displayed=strings_not_displayed ) self.add_repository_review_component( name='Repository dependencies', @@ -39,6 +84,11 @@ self.manage_review_components( strings_displayed=strings_displayed ) def test_0015_create_repository( self ): """Create and populate the filtering repository""" + """ + We are at step 4. + Log in as test_user_1 and create the filtering repository, then upload a basic set of + components to be reviewed in subsequent tests. + """ 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 ) @@ -53,21 +103,32 @@ 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.''' + """ + We are at step 5. + Log in as test_user_2 and review the data types component of the filtering repository owned by test_user_1. # 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 ) + # The create_repository_review method takes a dict( component label=review contents ). + # If review_contents is empty, it marks that component as not applicable. The review + # contents dict should have the structure: + # { + # rating: 1-5, + # comment: <text> + # approved: yes/no + # private: yes/no + # } 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.''' + """ + We are at step 6. + Log in as test_user_1 and check that the filtering repository only has a review for the data types component. + """ 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 ) @@ -76,11 +137,28 @@ 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.''' + '''Review the functional tests component for the current tip revision.''' + """ + We are at step 7. + Log in as test_user_2 and review the functional tests component for this repository. Since the repository + has not been altered, this will update the existing review to add a component. + # Review this revision: + # Data types (N/A) + # Functional tests (One star, comment 'functional tests missing') + """ 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 ) + # The create_repository_review method takes a dict( component label=review contents ). + # If review_contents is empty, it marks that component as not applicable. The review + # contents dict should have the structure: + # { + # rating: 1-5, + # comment: <text> + # approved: yes/no + # private: yes/no + # } 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 ): @@ -89,7 +167,13 @@ # 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.''' + '''Verify that the functional tests component review displays correctly.''' + """ + We are at step 8. + Log in as test_user_1 and check that the filtering repository now has reviews + for the data types and functional tests components. Since the functional tests component was not marked as 'Not applicable', + also check for the review comment. + """ 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 ) @@ -99,14 +183,35 @@ 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.''' + """ + We are at step 9. + Log in as test_user_2 and update the review with the readme component marked as 'Not applicable'. + # Review this revision: + # Data types (N/A) + # Functional tests (One star, comment 'functional tests missing') + # README (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 ) user = test_db_util.get_user( common.test_user_2_email ) + # The create_repository_review method takes a dict( component label=review contents ). + # If review_contents is empty, it marks that component as not applicable. The review + # contents dict should have the structure: + # { + # rating: 1-5, + # comment: <text> + # approved: yes/no + # private: yes/no + # } 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.''' + '''Verify that the readme component review displays correctly.''' + """ + We are at step 10. + Log in as test_user_1 and verify that the repository component reviews now include a review for the readme component. + """ 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 ) @@ -116,14 +221,37 @@ 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.''' + """ + We are at step 11. + Log in as test_user_2 and update the review with the repository dependencies component marked as 'Not applicable'. + # Review this revision: + # Data types (N/A) + # Functional tests (One star, comment 'functional tests missing') + # README (N/A) + # Repository dependencies (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 ) user = test_db_util.get_user( common.test_user_2_email ) + # The create_repository_review method takes a dict( component label=review contents ). + # If review_contents is empty, it marks that component as not applicable. The review + # contents dict should have the structure: + # { + # rating: 1-5, + # comment: <text> + # approved: yes/no + # private: yes/no + # } 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.''' + '''Verify that the repository dependencies component review displays correctly.''' + """ + We are at step 12. + Log in as test_user_1 and verify that the repository component reviews now include a review + for the repository dependencies component. + """ 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 ) @@ -133,14 +261,38 @@ 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.''' + """ + We are at step 13. + Log in as test_user_2 and update the review with the tool dependencies component marked as 'Not applicable'. + # 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) + """ 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 ) + # The create_repository_review method takes a dict( component label=review contents ). + # If review_contents is empty, it marks that component as not applicable. The review + # contents dict should have the structure: + # { + # rating: 1-5, + # comment: <text> + # approved: yes/no + # private: yes/no + # } 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.''' + '''Verify that the tool dependencies component review displays correctly.''' + """ + We are at step 14. + Log in as test_user_1 and verify that the repository component reviews now include a review + for the tool dependencies component. + """ 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 ) @@ -150,14 +302,40 @@ 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.''' + """ + We are at step 15. + Log in as test_user_2 and update the review with the tools component given + a favorable review, with 5 stars, and approved status. + # 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) + """ 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 ) + # The create_repository_review method takes a dict( component label=review contents ). + # If review_contents is empty, it marks that component as not applicable. The review + # contents dict should have the structure: + # { + # rating: 1-5, + # comment: <text> + # approved: yes/no + # private: yes/no + # } 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.''' + '''Verify that the tools component review displays correctly.''' + """ + We are at step 16. + Log in as test_user_1 and verify that the repository component reviews now include a review + for the tools component. As before, check for the presence of the comment on this review. + """ 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 ) @@ -167,14 +345,40 @@ 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.''' + """ + We are at step 17. + Log in as test_user_2 and update the review with the workflows component marked as 'Not applicable'. + # 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 ) user = test_db_util.get_user( common.test_user_2_email ) + # The create_repository_review method takes a dict( component label=review contents ). + # If review_contents is empty, it marks that component as not applicable. The review + # contents dict should have the structure: + # { + # rating: 1-5, + # comment: <text> + # approved: yes/no + # private: yes/no + # } 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.''' + '''Verify that the workflows component review displays correctly.''' + """ + We are at step 18. + Log in as test_user_1 and verify that the repository component reviews now include a review + for the workflows component. + """ 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 ) @@ -183,6 +387,11 @@ 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.''' + """ + We are at step 19. + Log in as test_user_1, the repository owner, and upload readme.txt to the repository. This will create + a new changeset revision for this repository, which will need to be reviewed. + """ 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 ) @@ -190,21 +399,42 @@ 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.''' + """ + We are at step 20. + There is now a new changeset revision in the repository's changelog, but it has no review associated with it. + Get the previously reviewed changeset hash, and pass that and the review id to the create_repository_review + method, in order to copy the previous review's contents. Then update the new review to reflect the presence of + a 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 ) ) + # Get the last changeset revision that has a review associated with it. + last_review = self.get_last_reviewed_revision_by_user( user, repository ) + if last_review is None: + raise AssertionError( 'Previous review expected, none found.' ) + # The create_repository_review method takes a dict( component label=review contents ). + # If review_contents is empty, it marks that component as not applicable. The review + # contents dict should have the structure: + # { + # rating: 1-5, + # comment: <text> + # approved: yes/no + # private: yes/no + # } 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 ) ) + copy_from=( str( last_review.changeset_revision ), last_review.id ) ) def test_0100_verify_readme_review( self ): '''Verify that the readme component review displays correctly.''' + """ + We are at step 21. + Log in as the repository owner (test_user_1) and check the repository component reviews to + verify that the readme component is now reviewed and approved. + """ 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 ) @@ -213,28 +443,51 @@ 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 ) + """ + We are at step 22. + Remain logged in as test_user_1 and upload test data to the repository. This will also create a + new changeset revision that needs to be reviewed. This will replace the changeset hash associated with + the last dowloadable revision, but the last repository review will still be associated with the + last dowloadable revision hash. + """ 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.''' + """ + We are at step 23. + Log in as test_user_2 and get the last reviewed changeset hash, and pass that and the review id to + the create_repository_review method, then update the copied review to approve the functional tests + component. + """ 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 ) ) + last_review = self.get_last_reviewed_revision_by_user( user, repository ) + # The create_repository_review method takes a dict( component label=review contents ). + # If review_contents is empty, it marks that component as not applicable. The review + # contents dict should have the structure: + # { + # rating: 1-5, + # comment: <text> + # approved: yes/no + # private: yes/no + # } 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 ) ) + copy_from=( str( last_review.changeset_revision ), last_review.id ) ) def test_0115_verify_functional_tests_review( self ): '''Verify that the functional tests component review displays correctly.''' + """ + We are at step 24. + Log in as the repository owner, test_user_1, and verify that the new revision's functional tests component + review has been updated with an approved status and favorable comment. + """ 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 ) @@ -243,6 +496,11 @@ 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.''' + """ + We are at step 25. + Log in as test_user_1 and upload a new version of the tool to the filtering repository. This will create + a new downloadable revision, with no associated repository component reviews. + """ 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 ) @@ -253,22 +511,38 @@ 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.''' + """ + We are at step 26. + Log in as test_user_2 and copy the last review for this repository to the new changeset. Then + update the tools component review to refer to the new tool version. + """ 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 ) ) + last_review = self.get_last_reviewed_revision_by_user( user, repository ) # Something needs to change so that the review will save. + # The create_repository_review method takes a dict( component label=review contents ). + # If review_contents is empty, it marks that component as not applicable. The review + # contents dict should have the structure: + # { + # rating: 1-5, + # comment: <text> + # approved: yes/no + # private: yes/no + # } 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 ) ) + copy_from=( str( last_review.changeset_revision ), last_review.id ) ) def test_0135_verify_review_for_new_version( self ): '''Verify that the reviews display correctly for this changeset revision.''' + """ + We are at step 27. + Log in as test_user_1 and check that the tools component review is for filtering 2.2.0, but that the other component + reviews had their contents copied from the last reviewed changeset. + """ 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 ) 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.