mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-13 00:44:55 +08:00
Tool shed functional test enhancement, made the grant_write_access method more robust, added functional test for contacting a repository's owner.
This commit is contained in:
@@ -587,13 +587,20 @@ class ShedTwillTestCase( TwillTestCase ):
|
||||
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=[] ):
|
||||
def grant_write_access( self,
|
||||
repository,
|
||||
usernames=[],
|
||||
strings_displayed=[],
|
||||
strings_not_displayed=[],
|
||||
post_submit_strings_displayed=[],
|
||||
post_submit_strings_not_displayed=[] ):
|
||||
self.display_manage_repository_page( repository )
|
||||
tc.fv( "3", "allow_push", '-Select one' )
|
||||
for username in usernames:
|
||||
tc.fv( "3", "allow_push", '+%s' % username )
|
||||
tc.submit( 'user_access_button' )
|
||||
self.check_for_strings( strings_displayed, strings_not_displayed )
|
||||
tc.fv( "user_access", "allow_push", '-Select one' )
|
||||
for username in usernames:
|
||||
tc.fv( "user_access", "allow_push", '+%s' % username )
|
||||
tc.submit( 'user_access_button' )
|
||||
self.check_for_strings( post_submit_strings_displayed, post_submit_strings_not_displayed )
|
||||
def import_workflow( self, repository, workflow_name, strings_displayed=[], strings_not_displayed=[] ):
|
||||
url = '/admin_toolshed/import_workflow?repository_id=%s&workflow_name=%s' % \
|
||||
( self.security.encode_id( repository.id ), tool_shed_encode( workflow_name ) )
|
||||
@@ -847,6 +854,19 @@ class ShedTwillTestCase( TwillTestCase ):
|
||||
tc.fv( "1", field_name, search_string )
|
||||
tc.submit()
|
||||
self.check_for_strings( strings_displayed, strings_not_displayed )
|
||||
def send_message_to_repository_owner( self,
|
||||
repository,
|
||||
message,
|
||||
strings_displayed=[],
|
||||
strings_not_displayed=[],
|
||||
post_submit_strings_displayed=[],
|
||||
post_submit_strings_not_displayed=[] ):
|
||||
url = '/repository/contact_owner?id=%s' % self.security.encode_id( repository.id )
|
||||
self.visit_url( url )
|
||||
self.check_for_strings( strings_displayed, strings_not_displayed )
|
||||
tc.fv( 1, 'message', message )
|
||||
tc.submit()
|
||||
self.check_for_strings( post_submit_strings_displayed, post_submit_strings_not_displayed )
|
||||
def set_repository_deprecated( self, repository, set_deprecated=True, strings_displayed=[], strings_not_displayed=[] ):
|
||||
url = '/repository/deprecate?id=%s&mark_deprecated=%s' % ( self.security.encode_id( repository.id ), set_deprecated )
|
||||
self.visit_url( url )
|
||||
|
||||
@@ -9,11 +9,17 @@ class TestBasicRepositoryFeatures( ShedTwillTestCase ):
|
||||
'''Test core repository features.'''
|
||||
def test_0000_initiate_users( self ):
|
||||
"""Create necessary user accounts and login as an admin user."""
|
||||
self.logout()
|
||||
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
|
||||
@@ -51,8 +57,8 @@ class TestBasicRepositoryFeatures( ShedTwillTestCase ):
|
||||
def test_0025_grant_write_access( self ):
|
||||
'''Grant write access to another user'''
|
||||
repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name )
|
||||
self.grant_write_access( repository, usernames=[ common.admin_username ] )
|
||||
self.revoke_write_access( repository, common.admin_username )
|
||||
self.grant_write_access( repository, usernames=[ common.test_user_2_name ] )
|
||||
self.revoke_write_access( repository, common.test_user_2_name )
|
||||
def test_0030_upload_filtering_1_1_0( self ):
|
||||
"""Upload filtering_1.1.0.tar to the repository"""
|
||||
repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name )
|
||||
@@ -214,3 +220,22 @@ class TestBasicRepositoryFeatures( ShedTwillTestCase ):
|
||||
assert test_user_1 is None, 'Creating user with public name "repos" succeeded.'
|
||||
error_message = 'The term <b>repos</b> is a reserved word in the tool shed, so it cannot be used as a public user name.'
|
||||
self.check_for_strings( strings_displayed=[ error_message ] )
|
||||
def test_0105_contact_repository_owner( self ):
|
||||
'''Fill out and submit the form to contact the owner of a repository.'''
|
||||
'''
|
||||
This test should not actually send the email, since functional tests are designed to function without
|
||||
any external network connection. The embedded tool shed server these tests are running against has been configured
|
||||
with an SMTP server address that will not and should not resolve correctly. However, since the successful sending of
|
||||
the email is the last step in the process, this will verify functional correctness of all preceding steps.
|
||||
'''
|
||||
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 )
|
||||
message = 'This is a test message.'
|
||||
strings_displayed = [ 'Contact the owner of the repository named', repository.name, 'streamline appropriate communication' ]
|
||||
post_submit_strings_displayed = [ 'An error occurred sending your message by email' ]
|
||||
self.send_message_to_repository_owner( repository=repository,
|
||||
message=message,
|
||||
strings_displayed=strings_displayed,
|
||||
post_submit_strings_displayed=post_submit_strings_displayed )
|
||||
|
||||
|
||||
@@ -199,6 +199,8 @@ def main():
|
||||
new_file_path = new_repos_path,
|
||||
running_functional_tests = True,
|
||||
shed_tool_data_table_config = shed_tool_data_table_conf_file,
|
||||
smtp_server = 'smtp.dummy.string.tld',
|
||||
email_from = 'functional@localhost',
|
||||
template_path = 'templates',
|
||||
tool_path=tool_path,
|
||||
tool_parse_help = False,
|
||||
|
||||
Reference in New Issue
Block a user