Skip to content

Commit

Permalink
Merge pull request #650 from nsoranzo/dev
Browse files Browse the repository at this point in the history
flake8 test/tool_shed/ . Fix 8 Tool Shed functional tests.
  • Loading branch information
martenson committed Aug 26, 2015
2 parents 4dc2f8c + fc2861c commit b0f2eae
Show file tree
Hide file tree
Showing 72 changed files with 3,431 additions and 3,337 deletions.
2 changes: 0 additions & 2 deletions .ci/flake8_blacklist.txt
Expand Up @@ -6,7 +6,6 @@ doc/patch.py
doc/source/conf.py
lib/galaxy/model/migrate/versions/
lib/galaxy/model/tool_shed_install/migrate/versions/
lib/galaxy/util/pastescript/serve.py
lib/galaxy/util/jstree.py
lib/galaxy/webapps/tool_shed/model/migrate/versions/
lib/pkg_resources.py
Expand All @@ -23,5 +22,4 @@ scripts/transfer.py
test/base/
test/casperjs/
test/install_and_test_tool_shed_repositories/
test/tool_shed/
tools/
14 changes: 5 additions & 9 deletions lib/galaxy/webapps/tool_shed/controllers/repository.py
Expand Up @@ -905,10 +905,8 @@ def check_for_updates( self, trans, **kwd ):
params = dict( tool_shed_url=web.url_for( '/', qualified=True ),
name=str( repository.name ),
owner=str( repository.user.username ),
changeset_revision=changeset_revision,
latest_changeset_revision=latest_changeset_revision )
changeset_revision=changeset_revision )
pathspec = [ 'admin_toolshed', 'update_to_changeset_revision' ]
url = common_util.url_join( galaxy_url, pathspec=pathspec, params=params )
else:
message = 'Unable to check for updates due to an invalid Galaxy URL: <b>%s</b>. ' % galaxy_url
message += 'You may need to enable third-party cookies in your browser. '
Expand All @@ -918,7 +916,6 @@ def check_for_updates( self, trans, **kwd ):
if from_update_manager:
return no_update
# Return the same value for changeset_revision and latest_changeset_revision.
url += latest_changeset_revision
else:
repository_metadata = suc.get_repository_metadata_by_changeset_revision( trans.app,
trans.security.encode_id( repository.id ),
Expand All @@ -928,9 +925,7 @@ def check_for_updates( self, trans, **kwd ):
# additional updates.
if from_update_manager:
return no_update
else:
# Return the same value for changeset_revision and latest_changeset_revision.
url += latest_changeset_revision
# Return the same value for changeset_revision and latest_changeset_revision.
else:
# The changeset_revision column in the repository_metadata table has been updated with a new
# changeset_revision value since the repository was installed. We need to find the changeset_revision
Expand Down Expand Up @@ -963,8 +958,9 @@ def check_for_updates( self, trans, **kwd ):
if latest_changeset_revision == changeset_revision:
return no_update
return update
url += str( latest_changeset_revision )
url += '&latest_ctx_rev=%s' % str( update_to_ctx.rev() )
params['latest_changeset_revision'] = str( latest_changeset_revision )
params['latest_ctx_rev'] = str( update_to_ctx.rev() )
url = common_util.url_join( galaxy_url, pathspec=pathspec, params=params )
return trans.response.send_redirect( url )

@web.expose
Expand Down
462 changes: 226 additions & 236 deletions test/tool_shed/base/twilltestcase.py

Large diffs are not rendered by default.

172 changes: 87 additions & 85 deletions test/tool_shed/functional/test_0000_basic_repository_features.py

Large diffs are not rendered by default.

@@ -1,4 +1,7 @@
from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os
import os

from tool_shed.base.twilltestcase import common, ShedTwillTestCase

repository_name = 'freebayes_0010'
repository_description = "Galaxy's freebayes tool"
repository_long_description = "Long description of Galaxy's freebayes tool"
Expand All @@ -13,145 +16,146 @@
7. Check for the appropriate strings on the manage repository page.
'''


class TestFreebayesRepository( ShedTwillTestCase ):
'''Testing freebayes with tool data table entries, .loc files, and tool dependencies.'''

def test_0000_create_or_login_admin_user( self ):
"""Create necessary user accounts and login as an admin user."""
self.logout()
self.login( email=common.test_user_1_email, username=common.test_user_1_name )
test_user_1 = self.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 = self.test_db_util.get_private_role( test_user_1 )
assert test_user_1 is not None, 'Problem retrieving user with email %s from the database' % common.test_user_1_email
self.test_db_util.get_private_role( test_user_1 )
self.logout()
self.login( email=common.admin_email, username=common.admin_username )
admin_user = self.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 = self.test_db_util.get_private_role( admin_user )
assert admin_user is not None, 'Problem retrieving user with email %s from the database' % common.admin_email
self.test_db_util.get_private_role( admin_user )

def test_0005_create_category( self ):
"""Create a category for this test suite"""
self.create_category( name='Test 0010 Repository With Tool Dependencies', description='Tests for a repository with tool dependencies.' )

def test_0010_create_freebayes_repository_and_upload_tool_xml( self ):
'''Create freebayes repository and upload only freebayes.xml.'''
'''
We are at step 1 - Create repository freebayes_0020 and upload only the tool XML.
Uploading only the tool XML file should result in an invalid tool and an error message on
upload, as well as on the manage repository page.
Uploading only the tool XML file should result in an invalid tool and an error message on
upload, as well as on the manage repository page.
'''
self.logout()
self.login( email=common.test_user_1_email, username=common.test_user_1_name )
category = self.test_db_util.get_category_by_name( 'Test 0010 Repository With Tool Dependencies' )
repository = self.get_or_create_repository( name=repository_name,
description=repository_description,
long_description=repository_long_description,
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 ),
category_id=self.security.encode_id( category.id ),
strings_displayed=[] )
self.upload_file( repository,
filename='freebayes/freebayes.xml',
self.upload_file( repository,
filename='freebayes/freebayes.xml',
filepath=None,
valid_tools_only=False,
uncompress_file=False,
remove_repo_files_not_in_tar=False,
commit_message='Uploaded the tool xml.',
strings_displayed=[ 'Metadata may have been defined', 'This file requires an entry', 'tool_data_table_conf' ],
strings_displayed=[ 'Metadata may have been defined', 'This file requires an entry', 'tool_data_table_conf' ],
strings_not_displayed=[] )
self.display_manage_repository_page( repository, strings_displayed=[ 'Invalid tools' ], strings_not_displayed=[ 'Valid tools' ] )
tip = self.get_repository_tip( repository )
strings_displayed = [ 'requires an entry', 'tool_data_table_conf.xml' ]
self.check_repository_invalid_tools_for_changeset_revision( repository, tip, strings_displayed=strings_displayed )

def test_0015_upload_missing_tool_data_table_conf_file( self ):
'''Upload the missing tool_data_table_conf.xml.sample file to the repository.'''
'''
We are at step 2 - Upload the tool_data_table_conf.xml.sample file.
Uploading the tool_data_table_conf.xml.sample alone should not make the tool valid, but the error message should change.
'''
repository = self.test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name )
self.upload_file( repository,
filename='freebayes/tool_data_table_conf.xml.sample',
self.upload_file( repository,
filename='freebayes/tool_data_table_conf.xml.sample',
filepath=None,
valid_tools_only=False,
uncompress_file=False,
remove_repo_files_not_in_tar=False,
commit_message='Uploaded the tool data table sample file.',
strings_displayed=[],
strings_displayed=[],
strings_not_displayed=[] )
self.display_manage_repository_page( repository, strings_displayed=[ 'Invalid tools' ], strings_not_displayed=[ 'Valid tools' ] )
tip = self.get_repository_tip( repository )
strings_displayed = [ 'refers to a file', 'sam_fa_indices.loc' ]
self.check_repository_invalid_tools_for_changeset_revision( repository, tip, strings_displayed=strings_displayed )

def test_0020_upload_missing_sample_loc_file( self ):
'''Upload the missing sam_fa_indices.loc.sample file to the repository.'''
'''
We are at step 3 - Upload the tool_data_table_conf.xml.sample file.
Uploading the tool_data_table_conf.xml.sample alone should not make the tool valid, but the error message should change.
'''
repository = self.test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name )
self.upload_file( repository,
filename='freebayes/sam_fa_indices.loc.sample',
self.upload_file( repository,
filename='freebayes/sam_fa_indices.loc.sample',
filepath=None,
valid_tools_only=True,
uncompress_file=False,
remove_repo_files_not_in_tar=False,
commit_message='Uploaded tool data table .loc file.',
strings_displayed=[],
strings_displayed=[],
strings_not_displayed=[] )

def test_0025_upload_malformed_tool_dependency_xml( self ):
'''Upload tool_dependencies.xml with bad characters in the readme tag.'''
'''
We are at step 4 - Upload a tool_dependencies.xml file that should not parse correctly.
Upload a tool_dependencies.xml file that contains <> in the text of the readme tag. This should show an error message about malformed xml.
'''
repository = self.test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name )
self.upload_file( repository,
filename=os.path.join( 'freebayes', 'malformed_tool_dependencies', 'tool_dependencies.xml' ),
self.upload_file( repository,
filename=os.path.join( 'freebayes', 'malformed_tool_dependencies', 'tool_dependencies.xml' ),
filepath=None,
valid_tools_only=False,
uncompress_file=False,
remove_repo_files_not_in_tar=False,
commit_message='Uploaded malformed tool dependency XML.',
strings_displayed=[ 'Exception attempting to parse', 'not well-formed' ],
strings_displayed=[ 'Exception attempting to parse', 'not well-formed' ],
strings_not_displayed=[] )

def test_0030_upload_invalid_tool_dependency_xml( self ):
'''Upload tool_dependencies.xml defining version 0.9.5 of the freebayes package.'''
'''
We are at step 5 - Upload a tool_dependencies.xml file that specifies a version that does not match the tool's requirements.
This should result in a message about the tool dependency configuration not matching the tool's requirements.
'''
repository = self.test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name )
self.upload_file( repository,
filename=os.path.join( 'freebayes', 'invalid_tool_dependencies', 'tool_dependencies.xml' ),
self.upload_file( repository,
filename=os.path.join( 'freebayes', 'invalid_tool_dependencies', 'tool_dependencies.xml' ),
filepath=None,
valid_tools_only=False,
uncompress_file=False,
remove_repo_files_not_in_tar=False,
commit_message='Uploaded invalid tool dependency XML.',
strings_displayed=[ 'The settings for <b>name</b>, <b>version</b> and <b>type</b> from a contained tool configuration' ],
strings_displayed=[ 'The settings for <b>name</b>, <b>version</b> and <b>type</b> from a contained tool configuration' ],
strings_not_displayed=[] )

def test_0035_upload_valid_tool_dependency_xml( self ):
'''Upload tool_dependencies.xml defining version 0.9.4_9696d0ce8a962f7bb61c4791be5ce44312b81cf8 of the freebayes package.'''
'''
We are at step 6 - Upload a valid tool_dependencies.xml file.
At this stage, there should be no errors on the upload page, as every missing or invalid file has been corrected.
'''
repository = self.test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name )
self.upload_file( repository,
filename=os.path.join( 'freebayes', 'tool_dependencies.xml' ),
self.upload_file( repository,
filename=os.path.join( 'freebayes', 'tool_dependencies.xml' ),
filepath=None,
valid_tools_only=True,
uncompress_file=False,
remove_repo_files_not_in_tar=False,
commit_message='Uploaded valid tool dependency XML.',
strings_displayed=[],
strings_displayed=[],
strings_not_displayed=[] )

def test_0040_verify_tool_dependencies( self ):
'''Verify that the uploaded tool_dependencies.xml specifies the correct package versions.'''
'''
Expand All @@ -160,5 +164,5 @@ def test_0040_verify_tool_dependencies( self ):
'''
repository = self.test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name )
strings_displayed = [ 'freebayes', '0.9.4_9696d0ce8a9', 'samtools', '0.1.18', 'Valid tools', 'package' ]
strings_not_displayed = [ 'Invalid tools' ]
strings_not_displayed = [ 'Invalid tools' ]
self.display_manage_repository_page( repository, strings_displayed=strings_displayed, strings_not_displayed=strings_not_displayed )

0 comments on commit b0f2eae

Please sign in to comment.