2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/1ab19b93abbd/ changeset: 1ab19b93abbd branch: next-stable user: inithello date: 2013-02-04 17:51:42 summary: Tool shed functional tests for complex repository dependencies, detection and setting of metadata for invalid repository dependencies. Fixes for detecting and displaying invalid repository dependencies. affected #: 10 files diff -r 73bb36c4ee3b34c3ca32ed830b4f91df79b971c5 -r 1ab19b93abbdf10d831dd2b9804a0081d7867fac lib/galaxy/util/shed_util_common.py --- a/lib/galaxy/util/shed_util_common.py +++ b/lib/galaxy/util/shed_util_common.py @@ -1292,8 +1292,8 @@ for repository_elem in root.findall( 'repository' ): current_rd_tups, error_message = handle_repository_elem( app, repository_elem, repository_dependencies_tups ) if error_message: + # Log the problem, but generate metadata for the invalid repository dependencies. log.debug( error_message ) - return metadata_dict, error_message for crdt in current_rd_tups: repository_dependencies_tups.append( crdt ) if repository_dependencies_tups: @@ -1868,10 +1868,12 @@ .first() # We're in the tool shed. user = get_user_by_username( app, owner ) - return sa_session.query( app.model.Repository ) \ - .filter( and_( app.model.Repository.table.c.name == name, - app.model.Repository.table.c.user_id == user.id ) ) \ - .first() + if user: + return sa_session.query( app.model.Repository ) \ + .filter( and_( app.model.Repository.table.c.name == name, + app.model.Repository.table.c.user_id == user.id ) ) \ + .first() + return None def get_repository_dependencies_for_changeset_revision( trans, repository, repository_metadata, toolshed_base_url, key_rd_dicts_to_be_processed=None, all_repository_dependencies=None, handled_key_rd_dicts=None, circular_repository_dependencies=None ): @@ -2284,9 +2286,13 @@ def get_user_by_username( app, username ): """Get a user from the database by username.""" sa_session = app.model.context.current - return sa_session.query( app.model.User ) \ - .filter( app.model.User.table.c.username == username ) \ - .one() + try: + user = sa_session.query( app.model.User ) \ + .filter( app.model.User.table.c.username == username ) \ + .one() + return user + except Exception, e: + return None def handle_circular_repository_dependency( repository_key, repository_dependency, circular_repository_dependencies, handled_key_rd_dicts, all_repository_dependencies ): all_repository_dependencies_root_key = all_repository_dependencies[ 'root_key' ] repository_dependency_as_key = get_repository_dependency_as_key( repository_dependency ) @@ -2510,6 +2516,11 @@ else: # We're in the tool shed. if tool_shed_is_this_tool_shed( toolshed ): + # Append the repository dependency definition regardless of whether it's valid or not, as Galaxy needs this to + # properly display an error when the repository dependency is invalid at the time of installation. + repository_dependencies_tup = ( toolshed, name, owner, changeset_revision ) + if repository_dependencies_tup not in new_rd_tups: + new_rd_tups.append( repository_dependencies_tup ) try: user = sa_session.query( app.model.User ) \ .filter( app.model.User.table.c.username == owner ) \ @@ -2539,9 +2550,6 @@ error_message = "Invalid changeset revision <b>%s</b> defined. Repository dependencies will be ignored." % str( changeset_revision ) log.debug( error_message ) return new_rd_tups, error_message - repository_dependencies_tup = ( toolshed, name, owner, changeset_revision ) - if repository_dependencies_tup not in new_rd_tups: - new_rd_tups.append( repository_dependencies_tup ) else: # Repository dependencies are currentlhy supported within a single tool shed. error_message = "Invalid tool shed <b>%s</b> defined for repository <b>%s</b>. " % ( toolshed, name ) @@ -3179,7 +3187,7 @@ updating_installed_repository=False, persist=False ) # We'll only display error messages for the repository tip (it may be better to display error messages for each installable changeset revision). - if current_metadata_dict == repository.tip( trans.app ): + if current_changeset_revision == repository.tip( trans.app ): invalid_file_tups.extend( invalid_tups ) if current_metadata_dict: if not metadata_changeset_revision and not metadata_dict: diff -r 73bb36c4ee3b34c3ca32ed830b4f91df79b971c5 -r 1ab19b93abbdf10d831dd2b9804a0081d7867fac run_functional_tests.sh --- a/run_functional_tests.sh +++ b/run_functional_tests.sh @@ -11,8 +11,8 @@ echo "'run_functional_tests.sh -id bbb' for testing one tool with id 'bbb' ('bbb' is the tool id)" echo "'run_functional_tests.sh -sid ccc' for testing one section with sid 'ccc' ('ccc' is the string after 'section::')" echo "'run_functional_tests.sh -list' for listing all the tool ids" - echo "'run_functional_tests.sh -toolshed' for running all the test scripts in the ./test/tool_shed/functional directory" - echo "'run_functional_tests.sh -toolshed testscriptname' for running one test script named testscriptname in the .test/tool_shed/functional directory" + echo "'run_functional_tests.sh -toolshed' for running all the test scripts in the ./test/tool_shed/functional directory" + echo "'run_functional_tests.sh -toolshed testscriptname' for running one test script named testscriptname in the .test/tool_shed/functional directory" elif [ $1 = '-id' ]; then python ./scripts/functional_tests.py -v functional.test_toolbox:TestForTool_$2 --with-nosehtml --html-report-file run_functional_tests.html elif [ $1 = '-sid' ]; then diff -r 73bb36c4ee3b34c3ca32ed830b4f91df79b971c5 -r 1ab19b93abbdf10d831dd2b9804a0081d7867fac test/tool_shed/base/twilltestcase.py --- a/test/tool_shed/base/twilltestcase.py +++ b/test/tool_shed/base/twilltestcase.py @@ -32,7 +32,7 @@ self.tool_data_path = os.environ.get( 'GALAXY_TEST_TOOL_DATA_PATH' ) self.shed_tool_conf = os.environ.get( 'GALAXY_TEST_SHED_TOOL_CONF' ) # TODO: Figure out a way to alter these attributes during tests. - self.galaxy_tool_dependency_dir = None # os.environ.get( 'GALAXY_TEST_TOOL_DEPENDENCY_DIR' ) + self.galaxy_tool_dependency_dir = os.environ.get( 'GALAXY_TEST_TOOL_DEPENDENCY_DIR' ) self.shed_tools_dict = {} self.home() def add_repository_review_component( self, **kwd ): @@ -450,6 +450,10 @@ dependency_template = string.Template( common.complex_repository_dependency_template ) repository_dependency_xml = dependency_template.safe_substitute( package=package, version=version, dependency_lines='\n'.join( dependency_entries ) ) else: + if not description: + description = ' description=""' + else: + description = ' description="%s"' % description template_parser = string.Template( common.new_repository_dependencies_xml ) repository_dependency_xml = template_parser.safe_substitute( description=description, dependency_lines='\n'.join( dependency_entries ) ) # Save the generated xml to the specified location. @@ -625,7 +629,8 @@ ( ','.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 ): + def install_repositories_from_search_results( self, repositories, install_tool_dependencies=False, + 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 @@ -640,15 +645,12 @@ 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 + kwd[ 'install_tool_dependencies' ] = 'True' else: checkbox.selected = False + kwd[ 'install_tool_dependencies' ] = 'False' self.submit_form( 1, 'select_tool_panel_section_button', **kwd ) repository_ids = self.initiate_installation_process() self.wait_for_repository_installation( repository_ids ) @@ -676,8 +678,10 @@ checkbox.disabled = False if install_tool_dependencies: checkbox.selected = True + kwd[ 'install_tool_dependencies' ] = 'True' else: checkbox.selected = False + kwd[ 'install_tool_dependencies' ] = 'False' if 'install_repository_dependencies' in self.last_page(): kwd[ 'install_repository_dependencies' ] = str( install_repository_dependencies ).lower() if 'shed_tool_conf' not in kwd: @@ -688,7 +692,7 @@ self.submit_form( 1, 'select_tool_panel_section_button', **kwd ) self.check_for_strings( post_submit_strings_displayed, strings_not_displayed ) else: - self.check_for_strings(strings_displayed=[ 'Choose the configuration file whose tool_path setting will be used for installing repositories' ] ) + self.check_for_strings( strings_displayed=[ 'Choose the configuration file whose tool_path setting will be used for installing repositories' ] ) args = dict( shed_tool_conf=self.shed_tool_conf ) self.submit_form( 1, 'select_shed_tool_panel_config_button', **args ) self.check_for_strings( post_submit_strings_displayed, strings_not_displayed ) diff -r 73bb36c4ee3b34c3ca32ed830b4f91df79b971c5 -r 1ab19b93abbdf10d831dd2b9804a0081d7867fac test/tool_shed/functional/test_0100_complex_repository_dependencies.py --- a/test/tool_shed/functional/test_0100_complex_repository_dependencies.py +++ b/test/tool_shed/functional/test_0100_complex_repository_dependencies.py @@ -60,15 +60,16 @@ commit_message='Uploaded bwa_base.tar with tool wrapper XML, but without tool dependency XML.' ) def test_0015_generate_complex_repository_dependency_invalid_shed_url( self ): '''Generate and upload a complex repository definition that specifies an invalid tool shed URL.''' - dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'shed' ] ) + dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'invalid' ] ) xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) url = 'http://http://this is not an url!' - name = repository.name - owner = repository.user.username - changeset_revision = self.get_repository_tip( repository ) + name = tool_repository.name + owner = tool_repository.user.username + changeset_revision = self.get_repository_tip( tool_repository ) self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=True, package='bwa', version='0.5.9' ) - strings_displayed = [ 'Invalid tool shed %s defined for repository %s' % ( url, repository.name ) ] + strings_displayed = [ 'Invalid tool shed <b>%s</b> defined' % url ] self.upload_file( repository, 'tool_dependencies.xml', valid_tools_only=False, @@ -77,16 +78,16 @@ strings_displayed=strings_displayed ) def test_0020_generate_complex_repository_dependency_invalid_repository_name( self ): '''Generate and upload a complex repository definition that specifies an invalid repository name.''' - dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'shed' ] ) + dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'invalid' ] ) xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) url = self.url name = 'invalid_repository!?' - owner = repository.user.username - changeset_revision = self.get_repository_tip( repository ) + owner = tool_repository.user.username + changeset_revision = self.get_repository_tip( tool_repository ) self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=True, package='bwa', version='0.5.9' ) - strings_displayed = 'Ignoring repository dependency definition for tool shed %s, name %s, owner %s' % ( url, name, owner ) - strings_displayed += ', changeset revision %s because the name is invalid.' % changeset_revision + strings_displayed = 'Invalid repository name <b>%s</b> defined.' % name self.upload_file( repository, 'tool_dependencies.xml', valid_tools_only=False, @@ -95,15 +96,16 @@ strings_displayed=[ strings_displayed ] ) def test_0025_generate_complex_repository_dependency_invalid_owner_name( self ): '''Generate and upload a complex repository definition that specifies an invalid owner.''' - dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'shed' ] ) + dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'invalid' ] ) xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) url = self.url - name = repository.name + name = tool_repository.name owner = 'invalid_owner!?' - changeset_revision = self.get_repository_tip( repository ) + changeset_revision = self.get_repository_tip( tool_repository ) self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=True, package='bwa', version='0.5.9' ) - strings_displayed = [ 'Invalid owner %s defined for repository %s. Repository dependencies will be ignored.' % ( owner, name ) ] + strings_displayed = [ 'Invalid owner <b>%s</b> defined' % owner ] self.upload_file( repository, 'tool_dependencies.xml', valid_tools_only=False, @@ -112,16 +114,16 @@ strings_displayed=strings_displayed ) def test_0030_generate_complex_repository_dependency_invalid_changeset_revision( self ): '''Generate and upload a complex repository definition that specifies an invalid changeset revision.''' - dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'shed' ] ) + dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'invalid' ] ) xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) url = self.url - name = repository.name - owner = repository.user.username + name = tool_repository.name + owner = tool_repository.user.username changeset_revision = '1234abcd' self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=True, package='bwa', version='0.5.9' ) - strings_displayed = 'Ignoring repository dependency definition for tool shed %s, name %s, owner %s' % ( url, name, owner ) - strings_displayed += ', changeset revision %s because the changeset revision is invalid.' % changeset_revision + strings_displayed = 'Invalid changeset revision <b>%s</b> defined.' % changeset_revision self.upload_file( repository, 'tool_dependencies.xml', valid_tools_only=False, @@ -129,13 +131,21 @@ commit_message='Uploaded dependency on bwa_tool_0100 with invalid changeset revision.', strings_displayed=[ strings_displayed ] ) def test_0035_generate_complex_repository_dependency( self ): - '''Generate and upload a tool_dependencies.xml file that specifies a repository rather than a tool.''' + '''Generate and upload a valid tool_dependencies.xml file that specifies bwa_tool_repository_0100.''' base_repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex' ] ) - self.create_repository_complex_dependency( base_repository, - self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ), - depends_on=dict( package='bwa', version='0.5.9', repositories=[ tool_repository ] ) ) + xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) + url = self.url + name = tool_repository.name + owner = tool_repository.user.username + changeset_revision = self.get_repository_tip( tool_repository ) + self.generate_repository_dependency_xml( [ tool_repository ], xml_filename, complex=True, package='bwa', version='0.5.9' ) + self.upload_file( base_repository, + 'tool_dependencies.xml', + valid_tools_only=True, + filepath=dependency_path, + commit_message='Uploaded valid complex dependency on bwa_tool_0100.' ) self.check_repository_dependency( base_repository, tool_repository ) self.display_manage_repository_page( base_repository, strings_displayed=[ 'bwa', '0.5.9', 'package' ] ) def test_0040_update_base_repository( self ): diff -r 73bb36c4ee3b34c3ca32ed830b4f91df79b971c5 -r 1ab19b93abbdf10d831dd2b9804a0081d7867fac test/tool_shed/functional/test_0110_invalid_simple_repository_dependencies.py --- /dev/null +++ b/test/tool_shed/functional/test_0110_invalid_simple_repository_dependencies.py @@ -0,0 +1,129 @@ +from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os +import tool_shed.base.test_db_util as test_db_util + +datatypes_repository_name = 'emboss_datatypes_0110' +datatypes_repository_description = "Galaxy applicable data formats used by Emboss tools." +datatypes_repository_long_description = "Galaxy applicable data formats used by Emboss tools. This repository contains no tools." + +emboss_repository_name = 'emboss_0110' +emboss_repository_description = 'Galaxy wrappers for Emboss version 5.0.0 tools' +emboss_repository_long_description = 'Galaxy wrappers for Emboss version 5.0.0 tools' + +category_name = 'Test 0110 Invalid Repository Dependencies' +category_desc = 'Test 0110 Invalid Repository Dependencies' + +class TestBasicRepositoryDependencies( ShedTwillTestCase ): + '''Testing emboss 5 with repository dependencies.''' + 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.admin_email, username=common.admin_username ) + admin_user = test_db_util.get_user( common.admin_email ) + assert admin_user is not None, 'Problem retrieving user with email %s from the database' % common.admin_email + admin_user_private_role = test_db_util.get_private_role( admin_user ) + def test_0005_create_category( self ): + """Create a category for this test suite""" + self.create_category( name=category_name, description=category_desc ) + def test_0010_create_emboss_datatypes_repository_and_upload_tarball( self ): + '''Create and populate the emboss_datatypes repository.''' + self.logout() + self.login( email=common.test_user_1_email, username=common.test_user_1_name ) + category = test_db_util.get_category_by_name( category_name ) + repository = self.get_or_create_repository( name=datatypes_repository_name, + description=datatypes_repository_description, + long_description=datatypes_repository_long_description, + owner=common.test_user_1_name, + category_id=self.security.encode_id( category.id ), + strings_displayed=[] ) + self.upload_file( repository, 'emboss/datatypes/datatypes_conf.xml', commit_message='Uploaded datatypes_conf.xml.' ) + def test_0015_verify_datatypes_in_datatypes_repository( self ): + '''Verify that the emboss_datatypes repository contains datatype entries.''' + repository = test_db_util.get_repository_by_name_and_owner( datatypes_repository_name, common.test_user_1_name ) + self.display_manage_repository_page( repository, strings_displayed=[ 'Datatypes', 'equicktandem', 'hennig86', 'vectorstrip' ] ) + def test_0020_create_emboss_5_repository_and_upload_files( self ): + '''Create and populate the emboss_5_0110 repository.''' + category = test_db_util.get_category_by_name( category_name ) + 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', commit_message='Uploaded emboss_5.tar' ) + def test_0025_generate_repository_dependency_with_invalid_url( self ): + '''Generate a repository dependency for emboss 5 with an invalid URL.''' + dependency_path = self.generate_temp_path( 'test_0110', additional_paths=[ 'simple' ] ) + xml_filename = self.get_filename( 'repository_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( 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 ) + url = 'http://http://this is not an url!' + name = repository.name + owner = repository.user.username + changeset_revision = self.get_repository_tip( repository ) + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=False, description='This is invalid.' ) + strings_displayed = [ 'Invalid tool shed <b>%s</b> defined for repository <b>%s</b>' % ( url, repository.name ) ] + self.upload_file( emboss_repository, + 'repository_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on emboss_datatypes_0110 with invalid url.', + strings_displayed=strings_displayed ) + def test_0030_generate_repository_dependency_with_invalid_name( self ): + '''Generate a repository dependency for emboss 5 with an invalid name.''' + dependency_path = self.generate_temp_path( 'test_0110', additional_paths=[ 'simple' ] ) + xml_filename = self.get_filename( 'repository_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( 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 ) + url = self.url + name = '!?invalid?!' + owner = repository.user.username + changeset_revision = self.get_repository_tip( repository ) + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=False, description='This is invalid.' ) + strings_displayed = [ 'Invalid repository name <b>%s</b> defined.' % name ] + self.upload_file( emboss_repository, + 'repository_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on emboss_datatypes_0110 with invalid url.', + strings_displayed=strings_displayed ) + def test_0035_generate_repository_dependency_with_invalid_owner( self ): + '''Generate a repository dependency for emboss 5 with an invalid owner.''' + dependency_path = self.generate_temp_path( 'test_0110', additional_paths=[ 'simple' ] ) + xml_filename = self.get_filename( 'repository_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( 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 ) + url = self.url + name = repository.name + owner = '!?invalid?!' + changeset_revision = self.get_repository_tip( repository ) + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=False, description='This is invalid.' ) + strings_displayed = [ 'Invalid owner <b>%s</b> defined for repository <b>%s</b>' % ( owner, repository.name ) ] + self.upload_file( emboss_repository, + 'repository_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on emboss_datatypes_0110 with invalid url.', + strings_displayed=strings_displayed ) + def test_0040_generate_repository_dependency_with_invalid_changeset_revision( self ): + '''Generate a repository dependency for emboss 5 with an invalid changeset revision.''' + dependency_path = self.generate_temp_path( 'test_0110', additional_paths=[ 'simple', 'invalid' ] ) + xml_filename = self.get_filename( 'repository_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( 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 ) + url = self.url + name = repository.name + owner = repository.user.username + changeset_revision = '!?invalid?!' + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=False, description='This is invalid.' ) + strings_displayed = [ 'Invalid changeset revision <b>%s</b> defined.' % changeset_revision ] + self.upload_file( emboss_repository, + 'repository_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on emboss_datatypes_0110 with invalid url.', + strings_displayed=strings_displayed ) diff -r 73bb36c4ee3b34c3ca32ed830b4f91df79b971c5 -r 1ab19b93abbdf10d831dd2b9804a0081d7867fac test/tool_shed/functional/test_1010_install_repository_with_tool_dependencies.py --- a/test/tool_shed/functional/test_1010_install_repository_with_tool_dependencies.py +++ b/test/tool_shed/functional/test_1010_install_repository_with_tool_dependencies.py @@ -72,8 +72,8 @@ self.preview_repository_in_tool_shed( repository_name, common.test_user_1_name, strings_displayed=strings_displayed ) def test_0015_install_freebayes_repository( self ): '''Install the freebayes repository without installing tool dependencies.''' - strings_displayed=[ 'Never installed', 'can be automatically installed', 'Set the tool_dependency_dir' ] - strings_displayed.extend( [ 'Handle', 'tool dependencies', 'freebayes', '0.9.4_9696d0ce8a9', 'samtools', '0.1.18' ] ) + strings_displayed=[ 'Never installed', 'dependencies can be automatically handled', 'Handle', 'tool dependencies' ] + strings_displayed.extend( [ 'freebayes', '0.9.4_9696d0ce8a9', 'samtools', '0.1.18' ] ) self.install_repository( repository_name, common.test_user_1_name, category_name, diff -r 73bb36c4ee3b34c3ca32ed830b4f91df79b971c5 -r 1ab19b93abbdf10d831dd2b9804a0081d7867fac test/tool_shed/functional/test_1087_install_updated_repository_dependencies.py --- a/test/tool_shed/functional/test_1087_install_updated_repository_dependencies.py +++ b/test/tool_shed/functional/test_1087_install_updated_repository_dependencies.py @@ -1,4 +1,4 @@ -from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os, logging +from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os import tool_shed.base.test_db_util as test_db_util column_repository_name = 'column_maker_1087' @@ -12,8 +12,6 @@ category_name = 'Test 1087 Advanced Circular Dependencies' category_description = 'Test circular dependency features' -log = logging.getLogger( __name__ ) - class TestRepositoryDependencies( ShedTwillTestCase ): '''Test installing a repository, then updating it to include repository dependencies.''' def test_0000_create_or_login_admin_user( self ): @@ -91,7 +89,6 @@ convert_repository = test_db_util.get_repository_by_name_and_owner( convert_repository_name, common.test_user_1_name ) column_repository = test_db_util.get_repository_by_name_and_owner( column_repository_name, common.test_user_1_name ) self.check_repository_dependency( column_repository, convert_repository ) - log.debug( [ repository.id for repository in test_db_util.get_all_installed_repositories() ] ) def test_0030_reinstall_column_repository( self ): '''Reinstall column_maker and verify that it now shows repository dependencies.''' installed_column_repository = test_db_util.get_installed_repository_by_name_owner( column_repository_name, common.test_user_1_name ) diff -r 73bb36c4ee3b34c3ca32ed830b4f91df79b971c5 -r 1ab19b93abbdf10d831dd2b9804a0081d7867fac test/tool_shed/functional/test_1100_install_repository_with_complex_dependencies.py --- /dev/null +++ b/test/tool_shed/functional/test_1100_install_repository_with_complex_dependencies.py @@ -0,0 +1,228 @@ +from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os +import tool_shed.base.test_db_util as test_db_util + +bwa_base_repository_name = 'bwa_base_repository_0100' +bwa_base_repository_description = "BWA Base" +bwa_base_repository_long_description = "BWA tool that depends on bwa 0.5.9, with a complex repository dependency pointing at bwa_tool_repository_0100" + +bwa_tool_repository_name = 'bwa_tool_repository_0100' +bwa_tool_repository_description = "BWA Tool" +bwa_tool_repository_long_description = "BWA repository with a package tool dependency defined for BWA 0.5.9." + +category_name = 'Test 0100 Complex Repository Dependencies' +category_description = 'Test 0100 Complex Repository Dependencies' +running_standalone = False + +class TestInstallingComplexRepositoryDependencies( ShedTwillTestCase ): + '''Test features related to installing repositories with complex 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_tool_repository( self ): + '''Create and populate bwa_tool_0100.''' + global running_standalone + 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_tool_repository_name, + description=bwa_tool_repository_description, + long_description=bwa_tool_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/complex/tool_dependencies.xml', + strings_displayed=[], + commit_message='Uploaded tool_dependencies.xml.' ) + self.display_manage_repository_page( repository, strings_displayed=[ 'Tool dependencies', 'may not be', 'in this repository' ] ) + def test_0010_create_bwa_base_repository( self ): + '''Create and populate bwa_base_0100.''' + global running_standalone + if running_standalone: + 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=[] ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) + self.upload_file( repository, + 'bwa/complex/bwa_base.tar', + strings_displayed=[], + commit_message='Uploaded bwa_base.tar with tool wrapper XML, but without tool dependency XML.' ) + def test_0015_generate_complex_repository_dependency_invalid_shed_url( self ): + '''Generate and upload a complex repository definition that specifies an invalid tool shed URL.''' + global running_standalone + if running_standalone: + dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'shed' ] ) + xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) + url = 'http://http://this is not an url!' + name = tool_repository.name + owner = tool_repository.user.username + changeset_revision = self.get_repository_tip( tool_repository ) + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=True, package='bwa', version='0.5.9' ) + strings_displayed = [ 'Invalid tool shed <b>%s</b> defined' % url ] + self.upload_file( repository, + 'tool_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on bwa_tool_0100 with invalid url.', + strings_displayed=strings_displayed ) + def test_0020_generate_complex_repository_dependency_invalid_repository_name( self ): + '''Generate and upload a complex repository definition that specifies an invalid repository name.''' + global running_standalone + if running_standalone: + dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'shed' ] ) + xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) + url = self.url + name = 'invalid_repository!?' + owner = tool_repository.user.username + changeset_revision = self.get_repository_tip( tool_repository ) + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=True, package='bwa', version='0.5.9' ) + strings_displayed = 'Invalid repository name <b>%s</b> defined.' % name + self.upload_file( repository, + 'tool_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on bwa_tool_0100 with invalid repository name.', + strings_displayed=[ strings_displayed ] ) + def test_0025_generate_complex_repository_dependency_invalid_owner_name( self ): + '''Generate and upload a complex repository definition that specifies an invalid owner.''' + global running_standalone + if running_standalone: + dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'shed' ] ) + xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) + url = self.url + name = tool_repository.name + owner = 'invalid_owner!?' + changeset_revision = self.get_repository_tip( tool_repository ) + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=True, package='bwa', version='0.5.9' ) + strings_displayed = [ 'Invalid owner <b>%s</b> defined' % owner ] + self.upload_file( repository, + 'tool_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on bwa_tool_0100 with invalid owner.', + strings_displayed=strings_displayed ) + def test_0030_generate_complex_repository_dependency_invalid_changeset_revision( self ): + '''Generate and upload a complex repository definition that specifies an invalid changeset revision.''' + global running_standalone + if running_standalone: + dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'shed' ] ) + xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) + url = self.url + name = tool_repository.name + owner = tool_repository.user.username + changeset_revision = '1234abcd' + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=True, package='bwa', version='0.5.9' ) + strings_displayed = 'Invalid changeset revision <b>%s</b> defined.' % changeset_revision + self.upload_file( repository, + 'tool_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on bwa_tool_0100 with invalid changeset revision.', + strings_displayed=[ strings_displayed ] ) + def test_0035_generate_valid_complex_repository_dependency( self ): + '''Generate and upload a valid tool_dependencies.xml file that specifies bwa_tool_repository_0100.''' + global running_standalone + if running_standalone: + base_repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) + dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex' ] ) + xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) + url = self.url + name = tool_repository.name + owner = tool_repository.user.username + changeset_revision = self.get_repository_tip( tool_repository ) + self.generate_repository_dependency_xml( [ tool_repository ], xml_filename, complex=True, package='bwa', version='0.5.9' ) + self.upload_file( base_repository, + 'tool_dependencies.xml', + valid_tools_only=True, + filepath=dependency_path, + commit_message='Uploaded valid complex dependency on bwa_tool_0100.' ) + self.check_repository_dependency( base_repository, tool_repository ) + self.display_manage_repository_page( base_repository, strings_displayed=[ 'bwa', '0.5.9', 'package' ] ) + def test_0040_update_tool_repository( self ): + '''Upload a new tool_dependencies.xml to the tool repository, and verify that the base repository displays the new changeset.''' + global running_standalone + if running_standalone: + base_repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) + previous_changeset = self.get_repository_tip( tool_repository ) + self.upload_file( tool_repository, + 'bwa/complex/readme/tool_dependencies.xml', + strings_displayed=[], + commit_message='Uploaded new tool_dependencies.xml.' ) + # Verify that the dependency display has been updated as a result of the new tool_dependencies.xml file. + self.display_manage_repository_page( base_repository, + strings_displayed=[ self.get_repository_tip( tool_repository ), 'bwa', '0.5.9', 'package' ], + strings_not_displayed=[ previous_changeset ] ) + def test_0045_install_base_repository( self ): + '''Verify installation of the repository with complex repository dependencies.''' + self.galaxy_logout() + self.galaxy_login( email=common.admin_email, username=common.admin_username ) + base_repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) + preview_strings_displayed = [ tool_repository.name, self.get_repository_tip( tool_repository ) ] + self.install_repository( bwa_base_repository_name, + common.test_user_1_name, + category_name, + install_tool_dependencies=True, + preview_strings_displayed=preview_strings_displayed, + post_submit_strings_displayed=[ base_repository.name, tool_repository.name, 'new' ], + includes_tools=True ) + def test_0050_verify_installed_repositories( self ): + '''Verify that the installed repositories are displayed properly.''' + base_repository = test_db_util.get_installed_repository_by_name_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_installed_repository_by_name_owner( bwa_tool_repository_name, common.test_user_1_name ) + strings_displayed = [ base_repository.name, base_repository.owner, base_repository.installed_changeset_revision ] + strings_displayed.extend( [ tool_repository.name, tool_repository.owner, tool_repository.installed_changeset_revision ] ) + strings_displayed.append( self.url.replace( 'http://', '' ) ) + self.display_galaxy_browse_repositories_page( strings_displayed=strings_displayed, strings_not_displayed=[] ) + checks = [ ( tool_repository, + [ tool_repository.name, tool_repository.owner, tool_repository.installed_changeset_revision ], + [ 'Missing tool dependencies' ] ), + ( base_repository, + [ base_repository.name, base_repository.owner, base_repository.installed_changeset_revision, tool_repository.name, + tool_repository.owner, tool_repository.installed_changeset_revision ], + [ 'Missing tool dependencies' ] ) ] + for repository, strings_displayed, strings_not_displayed in checks: + self.display_installed_repository_manage_page( repository, strings_displayed=strings_displayed, strings_not_displayed=strings_not_displayed ) + def test_0055_verify_complex_tool_dependency( self ): + '''Verify that the generated env.sh contains the right data.''' + base_repository = test_db_util.get_installed_repository_by_name_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_installed_repository_by_name_owner( bwa_tool_repository_name, common.test_user_1_name ) + env_sh_path = os.path.join( self.galaxy_tool_dependency_dir, + 'bwa', + '0.5.9', + base_repository.owner, + base_repository.name, + base_repository.installed_changeset_revision, + 'env.sh' ) + assert os.path.exists( env_sh_path ), 'env.sh was not generated in %s for this dependency.' % env_sh_path + contents = file( env_sh_path, 'r' ).read() + if tool_repository.installed_changeset_revision not in contents or tool_repository.name not in contents: + raise AssertionError( 'The env.sh file was not correctly generated. Contents: %s' % contents ) + diff -r 73bb36c4ee3b34c3ca32ed830b4f91df79b971c5 -r 1ab19b93abbdf10d831dd2b9804a0081d7867fac test/tool_shed/functional/test_1110_install_repository_with_invalid_repository_dependency.py --- /dev/null +++ b/test/tool_shed/functional/test_1110_install_repository_with_invalid_repository_dependency.py @@ -0,0 +1,159 @@ +from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os +import tool_shed.base.test_db_util as test_db_util + +datatypes_repository_name = 'emboss_datatypes_0110' +datatypes_repository_description = "Galaxy applicable data formats used by Emboss tools." +datatypes_repository_long_description = "Galaxy applicable data formats used by Emboss tools. This repository contains no tools." + +emboss_repository_name = 'emboss_0110' +emboss_repository_description = 'Galaxy wrappers for Emboss version 5.0.0 tools' +emboss_repository_long_description = 'Galaxy wrappers for Emboss version 5.0.0 tools' + +category_name = 'Test 0110 Invalid Repository Dependencies' +category_desc = 'Test 0110 Invalid Repository Dependencies' +running_standalone = False + +class TestBasicRepositoryDependencies( ShedTwillTestCase ): + '''Testing emboss 5 with repository dependencies.''' + 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.admin_email, username=common.admin_username ) + admin_user = test_db_util.get_user( common.admin_email ) + assert admin_user is not None, 'Problem retrieving user with email %s from the database' % common.admin_email + admin_user_private_role = test_db_util.get_private_role( admin_user ) + def test_0005_create_category( self ): + """Create a category for this test suite""" + self.create_category( name=category_name, description=category_desc ) + def test_0010_create_emboss_datatypes_repository_and_upload_tarball( self ): + '''Create and populate the emboss_datatypes repository.''' + global running_standalone + self.logout() + self.login( email=common.test_user_1_email, username=common.test_user_1_name ) + category = test_db_util.get_category_by_name( category_name ) + repository = self.get_or_create_repository( name=datatypes_repository_name, + description=datatypes_repository_description, + long_description=datatypes_repository_long_description, + owner=common.test_user_1_name, + category_id=self.security.encode_id( category.id ), + strings_displayed=[] ) + if self.repository_is_new( repository ): + running_standalone = True + self.upload_file( repository, 'emboss/datatypes/datatypes_conf.xml', commit_message='Uploaded datatypes_conf.xml.' ) + def test_0015_verify_datatypes_in_datatypes_repository( self ): + '''Verify that the emboss_datatypes repository contains datatype entries.''' + repository = test_db_util.get_repository_by_name_and_owner( datatypes_repository_name, common.test_user_1_name ) + self.display_manage_repository_page( repository, strings_displayed=[ 'Datatypes', 'equicktandem', 'hennig86', 'vectorstrip' ] ) + def test_0020_create_emboss_5_repository_and_upload_files( self ): + '''Create and populate the emboss_5_0110 repository.''' + global running_standalone + if running_standalone: + category = test_db_util.get_category_by_name( category_name ) + 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', commit_message='Uploaded emboss_5.tar' ) + def test_0025_generate_repository_dependency_with_invalid_url( self ): + '''Generate a repository dependency for emboss 5 with an invalid URL.''' + global running_standalone + if running_standalone: + dependency_path = self.generate_temp_path( 'test_0110', additional_paths=[ 'simple' ] ) + xml_filename = self.get_filename( 'repository_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( 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 ) + url = 'http://http://this is not an url!' + name = repository.name + owner = repository.user.username + changeset_revision = self.get_repository_tip( repository ) + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=False, description='This is invalid.' ) + strings_displayed = [ 'Invalid tool shed <b>%s</b> defined for repository <b>%s</b>' % ( url, repository.name ) ] + self.upload_file( emboss_repository, + 'repository_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on emboss_datatypes_0110 with invalid url.', + strings_displayed=strings_displayed ) + def test_0030_generate_repository_dependency_with_invalid_name( self ): + '''Generate a repository dependency for emboss 5 with an invalid name.''' + global running_standalone + if running_standalone: + dependency_path = self.generate_temp_path( 'test_0110', additional_paths=[ 'simple' ] ) + xml_filename = self.get_filename( 'repository_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( 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 ) + url = self.url + name = '!?invalid?!' + owner = repository.user.username + changeset_revision = self.get_repository_tip( repository ) + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=False, description='This is invalid.' ) + strings_displayed = [ 'Invalid repository name <b>%s</b> defined.' % name ] + self.upload_file( emboss_repository, + 'repository_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on emboss_datatypes_0110 with invalid name.', + strings_displayed=strings_displayed ) + def test_0035_generate_repository_dependency_with_invalid_owner( self ): + '''Generate a repository dependency for emboss 5 with an invalid owner.''' + global running_standalone + if running_standalone: + dependency_path = self.generate_temp_path( 'test_0110', additional_paths=[ 'simple' ] ) + xml_filename = self.get_filename( 'repository_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( 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 ) + url = self.url + name = repository.name + owner = '!?invalid?!' + changeset_revision = self.get_repository_tip( repository ) + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=False, description='This is invalid.' ) + strings_displayed = [ 'Invalid owner <b>%s</b> defined for repository <b>%s</b>' % ( owner, repository.name ) ] + self.upload_file( emboss_repository, + 'repository_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on emboss_datatypes_0110 with invalid owner.', + strings_displayed=strings_displayed ) + def test_0040_generate_repository_dependency_with_invalid_changeset_revision( self ): + '''Generate a repository dependency for emboss 5 with an invalid changeset revision.''' + global running_standalone + if running_standalone: + dependency_path = self.generate_temp_path( 'test_0110', additional_paths=[ 'simple', 'invalid' ] ) + xml_filename = self.get_filename( 'repository_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( 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 ) + url = self.url + name = repository.name + owner = repository.user.username + changeset_revision = '!?invalid?!' + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=False, description='This is invalid.' ) + strings_displayed = [ 'Invalid changeset revision <b>%s</b> defined.' % changeset_revision ] + self.upload_file( emboss_repository, + 'repository_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on emboss_datatypes_0110 with invalid changeset revision.', + strings_displayed=strings_displayed ) + def test_0045_install_repository_with_invalid_repository_dependency( self ): + '''Install the repository and verify that galaxy detects invalid repository dependencies.''' + self.galaxy_logout() + self.galaxy_login( email=common.admin_email, username=common.admin_username ) + repository = test_db_util.get_repository_by_name_and_owner( emboss_repository_name, common.test_user_1_name ) + preview_strings_displayed = [ repository.name, self.get_repository_tip( repository ), 'will be ignored' ] + self.install_repository( emboss_repository_name, + common.test_user_1_name, + category_name, + install_tool_dependencies=False, + install_repository_dependencies=True, + preview_strings_displayed=preview_strings_displayed, + post_submit_strings_displayed=[ repository.name, repository.name, 'new' ], + includes_tools=True ) + repository = test_db_util.get_installed_repository_by_name_owner( emboss_repository_name, common.test_user_1_name ) + self.display_installed_repository_manage_page( repository, strings_not_displayed=[ 'Repository dependencies' ] ) diff -r 73bb36c4ee3b34c3ca32ed830b4f91df79b971c5 -r 1ab19b93abbdf10d831dd2b9804a0081d7867fac test/tool_shed/functional_tests.py --- a/test/tool_shed/functional_tests.py +++ b/test/tool_shed/functional_tests.py @@ -288,6 +288,7 @@ shed_tool_path = galaxy_shed_tool_path, template_path = "templates", tool_data_path = tool_data_path, + tool_dependency_dir = galaxy_tool_dependency_dir, tool_path = tool_path, tool_config_file = [ galaxy_tool_conf_file, galaxy_shed_tool_conf_file ], tool_sheds_config_file = galaxy_tool_sheds_conf_file, @@ -391,18 +392,18 @@ galaxyapp.shutdown() galaxyapp = None log.info( "Embedded galaxy application stopped" ) - if 'TOOL_SHED_TEST_NO_CLEANUP' not in os.environ: - try: - for dir in [ tool_shed_test_tmp_dir ]: - if os.path.exists( dir ): - log.info( "Cleaning up temporary files in %s" % dir ) - shutil.rmtree( dir ) - except: - pass - if success: - return 0 - else: - return 1 +# if 'TOOL_SHED_TEST_NO_CLEANUP' not in os.environ: +# try: +# for dir in [ tool_shed_test_tmp_dir ]: +# if os.path.exists( dir ): +# log.info( "Cleaning up temporary files in %s" % dir ) +# shutil.rmtree( dir ) +# except: +# pass +# if success: +# return 0 +# else: +# return 1 if __name__ == "__main__": sys.exit( main() ) https://bitbucket.org/galaxy/galaxy-central/commits/596b4c29f842/ changeset: 596b4c29f842 user: inithello date: 2013-02-04 17:52:33 summary: Merged in changes from next-stable. affected #: 10 files diff -r 3de3a5a2d9b1f467ad5a7d855de84b2e2e7888a8 -r 596b4c29f84256767975caf9770d8c316d97386e lib/galaxy/util/shed_util_common.py --- a/lib/galaxy/util/shed_util_common.py +++ b/lib/galaxy/util/shed_util_common.py @@ -1292,8 +1292,8 @@ for repository_elem in root.findall( 'repository' ): current_rd_tups, error_message = handle_repository_elem( app, repository_elem, repository_dependencies_tups ) if error_message: + # Log the problem, but generate metadata for the invalid repository dependencies. log.debug( error_message ) - return metadata_dict, error_message for crdt in current_rd_tups: repository_dependencies_tups.append( crdt ) if repository_dependencies_tups: @@ -1868,10 +1868,12 @@ .first() # We're in the tool shed. user = get_user_by_username( app, owner ) - return sa_session.query( app.model.Repository ) \ - .filter( and_( app.model.Repository.table.c.name == name, - app.model.Repository.table.c.user_id == user.id ) ) \ - .first() + if user: + return sa_session.query( app.model.Repository ) \ + .filter( and_( app.model.Repository.table.c.name == name, + app.model.Repository.table.c.user_id == user.id ) ) \ + .first() + return None def get_repository_dependencies_for_changeset_revision( trans, repository, repository_metadata, toolshed_base_url, key_rd_dicts_to_be_processed=None, all_repository_dependencies=None, handled_key_rd_dicts=None, circular_repository_dependencies=None ): @@ -2284,9 +2286,13 @@ def get_user_by_username( app, username ): """Get a user from the database by username.""" sa_session = app.model.context.current - return sa_session.query( app.model.User ) \ - .filter( app.model.User.table.c.username == username ) \ - .one() + try: + user = sa_session.query( app.model.User ) \ + .filter( app.model.User.table.c.username == username ) \ + .one() + return user + except Exception, e: + return None def handle_circular_repository_dependency( repository_key, repository_dependency, circular_repository_dependencies, handled_key_rd_dicts, all_repository_dependencies ): all_repository_dependencies_root_key = all_repository_dependencies[ 'root_key' ] repository_dependency_as_key = get_repository_dependency_as_key( repository_dependency ) @@ -2510,6 +2516,11 @@ else: # We're in the tool shed. if tool_shed_is_this_tool_shed( toolshed ): + # Append the repository dependency definition regardless of whether it's valid or not, as Galaxy needs this to + # properly display an error when the repository dependency is invalid at the time of installation. + repository_dependencies_tup = ( toolshed, name, owner, changeset_revision ) + if repository_dependencies_tup not in new_rd_tups: + new_rd_tups.append( repository_dependencies_tup ) try: user = sa_session.query( app.model.User ) \ .filter( app.model.User.table.c.username == owner ) \ @@ -2539,9 +2550,6 @@ error_message = "Invalid changeset revision <b>%s</b> defined. Repository dependencies will be ignored." % str( changeset_revision ) log.debug( error_message ) return new_rd_tups, error_message - repository_dependencies_tup = ( toolshed, name, owner, changeset_revision ) - if repository_dependencies_tup not in new_rd_tups: - new_rd_tups.append( repository_dependencies_tup ) else: # Repository dependencies are currentlhy supported within a single tool shed. error_message = "Invalid tool shed <b>%s</b> defined for repository <b>%s</b>. " % ( toolshed, name ) @@ -3179,7 +3187,7 @@ updating_installed_repository=False, persist=False ) # We'll only display error messages for the repository tip (it may be better to display error messages for each installable changeset revision). - if current_metadata_dict == repository.tip( trans.app ): + if current_changeset_revision == repository.tip( trans.app ): invalid_file_tups.extend( invalid_tups ) if current_metadata_dict: if not metadata_changeset_revision and not metadata_dict: diff -r 3de3a5a2d9b1f467ad5a7d855de84b2e2e7888a8 -r 596b4c29f84256767975caf9770d8c316d97386e run_functional_tests.sh --- a/run_functional_tests.sh +++ b/run_functional_tests.sh @@ -11,8 +11,8 @@ echo "'run_functional_tests.sh -id bbb' for testing one tool with id 'bbb' ('bbb' is the tool id)" echo "'run_functional_tests.sh -sid ccc' for testing one section with sid 'ccc' ('ccc' is the string after 'section::')" echo "'run_functional_tests.sh -list' for listing all the tool ids" - echo "'run_functional_tests.sh -toolshed' for running all the test scripts in the ./test/tool_shed/functional directory" - echo "'run_functional_tests.sh -toolshed testscriptname' for running one test script named testscriptname in the .test/tool_shed/functional directory" + echo "'run_functional_tests.sh -toolshed' for running all the test scripts in the ./test/tool_shed/functional directory" + echo "'run_functional_tests.sh -toolshed testscriptname' for running one test script named testscriptname in the .test/tool_shed/functional directory" elif [ $1 = '-id' ]; then python ./scripts/functional_tests.py -v functional.test_toolbox:TestForTool_$2 --with-nosehtml --html-report-file run_functional_tests.html elif [ $1 = '-sid' ]; then diff -r 3de3a5a2d9b1f467ad5a7d855de84b2e2e7888a8 -r 596b4c29f84256767975caf9770d8c316d97386e test/tool_shed/base/twilltestcase.py --- a/test/tool_shed/base/twilltestcase.py +++ b/test/tool_shed/base/twilltestcase.py @@ -32,7 +32,7 @@ self.tool_data_path = os.environ.get( 'GALAXY_TEST_TOOL_DATA_PATH' ) self.shed_tool_conf = os.environ.get( 'GALAXY_TEST_SHED_TOOL_CONF' ) # TODO: Figure out a way to alter these attributes during tests. - self.galaxy_tool_dependency_dir = None # os.environ.get( 'GALAXY_TEST_TOOL_DEPENDENCY_DIR' ) + self.galaxy_tool_dependency_dir = os.environ.get( 'GALAXY_TEST_TOOL_DEPENDENCY_DIR' ) self.shed_tools_dict = {} self.home() def add_repository_review_component( self, **kwd ): @@ -450,6 +450,10 @@ dependency_template = string.Template( common.complex_repository_dependency_template ) repository_dependency_xml = dependency_template.safe_substitute( package=package, version=version, dependency_lines='\n'.join( dependency_entries ) ) else: + if not description: + description = ' description=""' + else: + description = ' description="%s"' % description template_parser = string.Template( common.new_repository_dependencies_xml ) repository_dependency_xml = template_parser.safe_substitute( description=description, dependency_lines='\n'.join( dependency_entries ) ) # Save the generated xml to the specified location. @@ -625,7 +629,8 @@ ( ','.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 ): + def install_repositories_from_search_results( self, repositories, install_tool_dependencies=False, + 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 @@ -640,15 +645,12 @@ 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 + kwd[ 'install_tool_dependencies' ] = 'True' else: checkbox.selected = False + kwd[ 'install_tool_dependencies' ] = 'False' self.submit_form( 1, 'select_tool_panel_section_button', **kwd ) repository_ids = self.initiate_installation_process() self.wait_for_repository_installation( repository_ids ) @@ -676,8 +678,10 @@ checkbox.disabled = False if install_tool_dependencies: checkbox.selected = True + kwd[ 'install_tool_dependencies' ] = 'True' else: checkbox.selected = False + kwd[ 'install_tool_dependencies' ] = 'False' if 'install_repository_dependencies' in self.last_page(): kwd[ 'install_repository_dependencies' ] = str( install_repository_dependencies ).lower() if 'shed_tool_conf' not in kwd: @@ -688,7 +692,7 @@ self.submit_form( 1, 'select_tool_panel_section_button', **kwd ) self.check_for_strings( post_submit_strings_displayed, strings_not_displayed ) else: - self.check_for_strings(strings_displayed=[ 'Choose the configuration file whose tool_path setting will be used for installing repositories' ] ) + self.check_for_strings( strings_displayed=[ 'Choose the configuration file whose tool_path setting will be used for installing repositories' ] ) args = dict( shed_tool_conf=self.shed_tool_conf ) self.submit_form( 1, 'select_shed_tool_panel_config_button', **args ) self.check_for_strings( post_submit_strings_displayed, strings_not_displayed ) diff -r 3de3a5a2d9b1f467ad5a7d855de84b2e2e7888a8 -r 596b4c29f84256767975caf9770d8c316d97386e test/tool_shed/functional/test_0100_complex_repository_dependencies.py --- a/test/tool_shed/functional/test_0100_complex_repository_dependencies.py +++ b/test/tool_shed/functional/test_0100_complex_repository_dependencies.py @@ -60,15 +60,16 @@ commit_message='Uploaded bwa_base.tar with tool wrapper XML, but without tool dependency XML.' ) def test_0015_generate_complex_repository_dependency_invalid_shed_url( self ): '''Generate and upload a complex repository definition that specifies an invalid tool shed URL.''' - dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'shed' ] ) + dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'invalid' ] ) xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) url = 'http://http://this is not an url!' - name = repository.name - owner = repository.user.username - changeset_revision = self.get_repository_tip( repository ) + name = tool_repository.name + owner = tool_repository.user.username + changeset_revision = self.get_repository_tip( tool_repository ) self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=True, package='bwa', version='0.5.9' ) - strings_displayed = [ 'Invalid tool shed %s defined for repository %s' % ( url, repository.name ) ] + strings_displayed = [ 'Invalid tool shed <b>%s</b> defined' % url ] self.upload_file( repository, 'tool_dependencies.xml', valid_tools_only=False, @@ -77,16 +78,16 @@ strings_displayed=strings_displayed ) def test_0020_generate_complex_repository_dependency_invalid_repository_name( self ): '''Generate and upload a complex repository definition that specifies an invalid repository name.''' - dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'shed' ] ) + dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'invalid' ] ) xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) url = self.url name = 'invalid_repository!?' - owner = repository.user.username - changeset_revision = self.get_repository_tip( repository ) + owner = tool_repository.user.username + changeset_revision = self.get_repository_tip( tool_repository ) self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=True, package='bwa', version='0.5.9' ) - strings_displayed = 'Ignoring repository dependency definition for tool shed %s, name %s, owner %s' % ( url, name, owner ) - strings_displayed += ', changeset revision %s because the name is invalid.' % changeset_revision + strings_displayed = 'Invalid repository name <b>%s</b> defined.' % name self.upload_file( repository, 'tool_dependencies.xml', valid_tools_only=False, @@ -95,15 +96,16 @@ strings_displayed=[ strings_displayed ] ) def test_0025_generate_complex_repository_dependency_invalid_owner_name( self ): '''Generate and upload a complex repository definition that specifies an invalid owner.''' - dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'shed' ] ) + dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'invalid' ] ) xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) url = self.url - name = repository.name + name = tool_repository.name owner = 'invalid_owner!?' - changeset_revision = self.get_repository_tip( repository ) + changeset_revision = self.get_repository_tip( tool_repository ) self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=True, package='bwa', version='0.5.9' ) - strings_displayed = [ 'Invalid owner %s defined for repository %s. Repository dependencies will be ignored.' % ( owner, name ) ] + strings_displayed = [ 'Invalid owner <b>%s</b> defined' % owner ] self.upload_file( repository, 'tool_dependencies.xml', valid_tools_only=False, @@ -112,16 +114,16 @@ strings_displayed=strings_displayed ) def test_0030_generate_complex_repository_dependency_invalid_changeset_revision( self ): '''Generate and upload a complex repository definition that specifies an invalid changeset revision.''' - dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'shed' ] ) + dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'invalid' ] ) xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) url = self.url - name = repository.name - owner = repository.user.username + name = tool_repository.name + owner = tool_repository.user.username changeset_revision = '1234abcd' self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=True, package='bwa', version='0.5.9' ) - strings_displayed = 'Ignoring repository dependency definition for tool shed %s, name %s, owner %s' % ( url, name, owner ) - strings_displayed += ', changeset revision %s because the changeset revision is invalid.' % changeset_revision + strings_displayed = 'Invalid changeset revision <b>%s</b> defined.' % changeset_revision self.upload_file( repository, 'tool_dependencies.xml', valid_tools_only=False, @@ -129,13 +131,21 @@ commit_message='Uploaded dependency on bwa_tool_0100 with invalid changeset revision.', strings_displayed=[ strings_displayed ] ) def test_0035_generate_complex_repository_dependency( self ): - '''Generate and upload a tool_dependencies.xml file that specifies a repository rather than a tool.''' + '''Generate and upload a valid tool_dependencies.xml file that specifies bwa_tool_repository_0100.''' base_repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex' ] ) - self.create_repository_complex_dependency( base_repository, - self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ), - depends_on=dict( package='bwa', version='0.5.9', repositories=[ tool_repository ] ) ) + xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) + url = self.url + name = tool_repository.name + owner = tool_repository.user.username + changeset_revision = self.get_repository_tip( tool_repository ) + self.generate_repository_dependency_xml( [ tool_repository ], xml_filename, complex=True, package='bwa', version='0.5.9' ) + self.upload_file( base_repository, + 'tool_dependencies.xml', + valid_tools_only=True, + filepath=dependency_path, + commit_message='Uploaded valid complex dependency on bwa_tool_0100.' ) self.check_repository_dependency( base_repository, tool_repository ) self.display_manage_repository_page( base_repository, strings_displayed=[ 'bwa', '0.5.9', 'package' ] ) def test_0040_update_base_repository( self ): diff -r 3de3a5a2d9b1f467ad5a7d855de84b2e2e7888a8 -r 596b4c29f84256767975caf9770d8c316d97386e test/tool_shed/functional/test_0110_invalid_simple_repository_dependencies.py --- /dev/null +++ b/test/tool_shed/functional/test_0110_invalid_simple_repository_dependencies.py @@ -0,0 +1,129 @@ +from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os +import tool_shed.base.test_db_util as test_db_util + +datatypes_repository_name = 'emboss_datatypes_0110' +datatypes_repository_description = "Galaxy applicable data formats used by Emboss tools." +datatypes_repository_long_description = "Galaxy applicable data formats used by Emboss tools. This repository contains no tools." + +emboss_repository_name = 'emboss_0110' +emboss_repository_description = 'Galaxy wrappers for Emboss version 5.0.0 tools' +emboss_repository_long_description = 'Galaxy wrappers for Emboss version 5.0.0 tools' + +category_name = 'Test 0110 Invalid Repository Dependencies' +category_desc = 'Test 0110 Invalid Repository Dependencies' + +class TestBasicRepositoryDependencies( ShedTwillTestCase ): + '''Testing emboss 5 with repository dependencies.''' + 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.admin_email, username=common.admin_username ) + admin_user = test_db_util.get_user( common.admin_email ) + assert admin_user is not None, 'Problem retrieving user with email %s from the database' % common.admin_email + admin_user_private_role = test_db_util.get_private_role( admin_user ) + def test_0005_create_category( self ): + """Create a category for this test suite""" + self.create_category( name=category_name, description=category_desc ) + def test_0010_create_emboss_datatypes_repository_and_upload_tarball( self ): + '''Create and populate the emboss_datatypes repository.''' + self.logout() + self.login( email=common.test_user_1_email, username=common.test_user_1_name ) + category = test_db_util.get_category_by_name( category_name ) + repository = self.get_or_create_repository( name=datatypes_repository_name, + description=datatypes_repository_description, + long_description=datatypes_repository_long_description, + owner=common.test_user_1_name, + category_id=self.security.encode_id( category.id ), + strings_displayed=[] ) + self.upload_file( repository, 'emboss/datatypes/datatypes_conf.xml', commit_message='Uploaded datatypes_conf.xml.' ) + def test_0015_verify_datatypes_in_datatypes_repository( self ): + '''Verify that the emboss_datatypes repository contains datatype entries.''' + repository = test_db_util.get_repository_by_name_and_owner( datatypes_repository_name, common.test_user_1_name ) + self.display_manage_repository_page( repository, strings_displayed=[ 'Datatypes', 'equicktandem', 'hennig86', 'vectorstrip' ] ) + def test_0020_create_emboss_5_repository_and_upload_files( self ): + '''Create and populate the emboss_5_0110 repository.''' + category = test_db_util.get_category_by_name( category_name ) + 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', commit_message='Uploaded emboss_5.tar' ) + def test_0025_generate_repository_dependency_with_invalid_url( self ): + '''Generate a repository dependency for emboss 5 with an invalid URL.''' + dependency_path = self.generate_temp_path( 'test_0110', additional_paths=[ 'simple' ] ) + xml_filename = self.get_filename( 'repository_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( 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 ) + url = 'http://http://this is not an url!' + name = repository.name + owner = repository.user.username + changeset_revision = self.get_repository_tip( repository ) + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=False, description='This is invalid.' ) + strings_displayed = [ 'Invalid tool shed <b>%s</b> defined for repository <b>%s</b>' % ( url, repository.name ) ] + self.upload_file( emboss_repository, + 'repository_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on emboss_datatypes_0110 with invalid url.', + strings_displayed=strings_displayed ) + def test_0030_generate_repository_dependency_with_invalid_name( self ): + '''Generate a repository dependency for emboss 5 with an invalid name.''' + dependency_path = self.generate_temp_path( 'test_0110', additional_paths=[ 'simple' ] ) + xml_filename = self.get_filename( 'repository_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( 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 ) + url = self.url + name = '!?invalid?!' + owner = repository.user.username + changeset_revision = self.get_repository_tip( repository ) + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=False, description='This is invalid.' ) + strings_displayed = [ 'Invalid repository name <b>%s</b> defined.' % name ] + self.upload_file( emboss_repository, + 'repository_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on emboss_datatypes_0110 with invalid url.', + strings_displayed=strings_displayed ) + def test_0035_generate_repository_dependency_with_invalid_owner( self ): + '''Generate a repository dependency for emboss 5 with an invalid owner.''' + dependency_path = self.generate_temp_path( 'test_0110', additional_paths=[ 'simple' ] ) + xml_filename = self.get_filename( 'repository_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( 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 ) + url = self.url + name = repository.name + owner = '!?invalid?!' + changeset_revision = self.get_repository_tip( repository ) + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=False, description='This is invalid.' ) + strings_displayed = [ 'Invalid owner <b>%s</b> defined for repository <b>%s</b>' % ( owner, repository.name ) ] + self.upload_file( emboss_repository, + 'repository_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on emboss_datatypes_0110 with invalid url.', + strings_displayed=strings_displayed ) + def test_0040_generate_repository_dependency_with_invalid_changeset_revision( self ): + '''Generate a repository dependency for emboss 5 with an invalid changeset revision.''' + dependency_path = self.generate_temp_path( 'test_0110', additional_paths=[ 'simple', 'invalid' ] ) + xml_filename = self.get_filename( 'repository_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( 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 ) + url = self.url + name = repository.name + owner = repository.user.username + changeset_revision = '!?invalid?!' + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=False, description='This is invalid.' ) + strings_displayed = [ 'Invalid changeset revision <b>%s</b> defined.' % changeset_revision ] + self.upload_file( emboss_repository, + 'repository_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on emboss_datatypes_0110 with invalid url.', + strings_displayed=strings_displayed ) diff -r 3de3a5a2d9b1f467ad5a7d855de84b2e2e7888a8 -r 596b4c29f84256767975caf9770d8c316d97386e test/tool_shed/functional/test_1010_install_repository_with_tool_dependencies.py --- a/test/tool_shed/functional/test_1010_install_repository_with_tool_dependencies.py +++ b/test/tool_shed/functional/test_1010_install_repository_with_tool_dependencies.py @@ -72,8 +72,8 @@ self.preview_repository_in_tool_shed( repository_name, common.test_user_1_name, strings_displayed=strings_displayed ) def test_0015_install_freebayes_repository( self ): '''Install the freebayes repository without installing tool dependencies.''' - strings_displayed=[ 'Never installed', 'can be automatically installed', 'Set the tool_dependency_dir' ] - strings_displayed.extend( [ 'Handle', 'tool dependencies', 'freebayes', '0.9.4_9696d0ce8a9', 'samtools', '0.1.18' ] ) + strings_displayed=[ 'Never installed', 'dependencies can be automatically handled', 'Handle', 'tool dependencies' ] + strings_displayed.extend( [ 'freebayes', '0.9.4_9696d0ce8a9', 'samtools', '0.1.18' ] ) self.install_repository( repository_name, common.test_user_1_name, category_name, diff -r 3de3a5a2d9b1f467ad5a7d855de84b2e2e7888a8 -r 596b4c29f84256767975caf9770d8c316d97386e test/tool_shed/functional/test_1087_install_updated_repository_dependencies.py --- a/test/tool_shed/functional/test_1087_install_updated_repository_dependencies.py +++ b/test/tool_shed/functional/test_1087_install_updated_repository_dependencies.py @@ -1,4 +1,4 @@ -from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os, logging +from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os import tool_shed.base.test_db_util as test_db_util column_repository_name = 'column_maker_1087' @@ -12,8 +12,6 @@ category_name = 'Test 1087 Advanced Circular Dependencies' category_description = 'Test circular dependency features' -log = logging.getLogger( __name__ ) - class TestRepositoryDependencies( ShedTwillTestCase ): '''Test installing a repository, then updating it to include repository dependencies.''' def test_0000_create_or_login_admin_user( self ): @@ -91,7 +89,6 @@ convert_repository = test_db_util.get_repository_by_name_and_owner( convert_repository_name, common.test_user_1_name ) column_repository = test_db_util.get_repository_by_name_and_owner( column_repository_name, common.test_user_1_name ) self.check_repository_dependency( column_repository, convert_repository ) - log.debug( [ repository.id for repository in test_db_util.get_all_installed_repositories() ] ) def test_0030_reinstall_column_repository( self ): '''Reinstall column_maker and verify that it now shows repository dependencies.''' installed_column_repository = test_db_util.get_installed_repository_by_name_owner( column_repository_name, common.test_user_1_name ) diff -r 3de3a5a2d9b1f467ad5a7d855de84b2e2e7888a8 -r 596b4c29f84256767975caf9770d8c316d97386e test/tool_shed/functional/test_1100_install_repository_with_complex_dependencies.py --- /dev/null +++ b/test/tool_shed/functional/test_1100_install_repository_with_complex_dependencies.py @@ -0,0 +1,228 @@ +from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os +import tool_shed.base.test_db_util as test_db_util + +bwa_base_repository_name = 'bwa_base_repository_0100' +bwa_base_repository_description = "BWA Base" +bwa_base_repository_long_description = "BWA tool that depends on bwa 0.5.9, with a complex repository dependency pointing at bwa_tool_repository_0100" + +bwa_tool_repository_name = 'bwa_tool_repository_0100' +bwa_tool_repository_description = "BWA Tool" +bwa_tool_repository_long_description = "BWA repository with a package tool dependency defined for BWA 0.5.9." + +category_name = 'Test 0100 Complex Repository Dependencies' +category_description = 'Test 0100 Complex Repository Dependencies' +running_standalone = False + +class TestInstallingComplexRepositoryDependencies( ShedTwillTestCase ): + '''Test features related to installing repositories with complex 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_tool_repository( self ): + '''Create and populate bwa_tool_0100.''' + global running_standalone + 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_tool_repository_name, + description=bwa_tool_repository_description, + long_description=bwa_tool_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/complex/tool_dependencies.xml', + strings_displayed=[], + commit_message='Uploaded tool_dependencies.xml.' ) + self.display_manage_repository_page( repository, strings_displayed=[ 'Tool dependencies', 'may not be', 'in this repository' ] ) + def test_0010_create_bwa_base_repository( self ): + '''Create and populate bwa_base_0100.''' + global running_standalone + if running_standalone: + 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=[] ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) + self.upload_file( repository, + 'bwa/complex/bwa_base.tar', + strings_displayed=[], + commit_message='Uploaded bwa_base.tar with tool wrapper XML, but without tool dependency XML.' ) + def test_0015_generate_complex_repository_dependency_invalid_shed_url( self ): + '''Generate and upload a complex repository definition that specifies an invalid tool shed URL.''' + global running_standalone + if running_standalone: + dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'shed' ] ) + xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) + url = 'http://http://this is not an url!' + name = tool_repository.name + owner = tool_repository.user.username + changeset_revision = self.get_repository_tip( tool_repository ) + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=True, package='bwa', version='0.5.9' ) + strings_displayed = [ 'Invalid tool shed <b>%s</b> defined' % url ] + self.upload_file( repository, + 'tool_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on bwa_tool_0100 with invalid url.', + strings_displayed=strings_displayed ) + def test_0020_generate_complex_repository_dependency_invalid_repository_name( self ): + '''Generate and upload a complex repository definition that specifies an invalid repository name.''' + global running_standalone + if running_standalone: + dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'shed' ] ) + xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) + url = self.url + name = 'invalid_repository!?' + owner = tool_repository.user.username + changeset_revision = self.get_repository_tip( tool_repository ) + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=True, package='bwa', version='0.5.9' ) + strings_displayed = 'Invalid repository name <b>%s</b> defined.' % name + self.upload_file( repository, + 'tool_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on bwa_tool_0100 with invalid repository name.', + strings_displayed=[ strings_displayed ] ) + def test_0025_generate_complex_repository_dependency_invalid_owner_name( self ): + '''Generate and upload a complex repository definition that specifies an invalid owner.''' + global running_standalone + if running_standalone: + dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'shed' ] ) + xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) + url = self.url + name = tool_repository.name + owner = 'invalid_owner!?' + changeset_revision = self.get_repository_tip( tool_repository ) + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=True, package='bwa', version='0.5.9' ) + strings_displayed = [ 'Invalid owner <b>%s</b> defined' % owner ] + self.upload_file( repository, + 'tool_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on bwa_tool_0100 with invalid owner.', + strings_displayed=strings_displayed ) + def test_0030_generate_complex_repository_dependency_invalid_changeset_revision( self ): + '''Generate and upload a complex repository definition that specifies an invalid changeset revision.''' + global running_standalone + if running_standalone: + dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex', 'shed' ] ) + xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) + url = self.url + name = tool_repository.name + owner = tool_repository.user.username + changeset_revision = '1234abcd' + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=True, package='bwa', version='0.5.9' ) + strings_displayed = 'Invalid changeset revision <b>%s</b> defined.' % changeset_revision + self.upload_file( repository, + 'tool_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on bwa_tool_0100 with invalid changeset revision.', + strings_displayed=[ strings_displayed ] ) + def test_0035_generate_valid_complex_repository_dependency( self ): + '''Generate and upload a valid tool_dependencies.xml file that specifies bwa_tool_repository_0100.''' + global running_standalone + if running_standalone: + base_repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) + dependency_path = self.generate_temp_path( 'test_0100', additional_paths=[ 'complex' ] ) + xml_filename = self.get_filename( 'tool_dependencies.xml', filepath=dependency_path ) + url = self.url + name = tool_repository.name + owner = tool_repository.user.username + changeset_revision = self.get_repository_tip( tool_repository ) + self.generate_repository_dependency_xml( [ tool_repository ], xml_filename, complex=True, package='bwa', version='0.5.9' ) + self.upload_file( base_repository, + 'tool_dependencies.xml', + valid_tools_only=True, + filepath=dependency_path, + commit_message='Uploaded valid complex dependency on bwa_tool_0100.' ) + self.check_repository_dependency( base_repository, tool_repository ) + self.display_manage_repository_page( base_repository, strings_displayed=[ 'bwa', '0.5.9', 'package' ] ) + def test_0040_update_tool_repository( self ): + '''Upload a new tool_dependencies.xml to the tool repository, and verify that the base repository displays the new changeset.''' + global running_standalone + if running_standalone: + base_repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) + previous_changeset = self.get_repository_tip( tool_repository ) + self.upload_file( tool_repository, + 'bwa/complex/readme/tool_dependencies.xml', + strings_displayed=[], + commit_message='Uploaded new tool_dependencies.xml.' ) + # Verify that the dependency display has been updated as a result of the new tool_dependencies.xml file. + self.display_manage_repository_page( base_repository, + strings_displayed=[ self.get_repository_tip( tool_repository ), 'bwa', '0.5.9', 'package' ], + strings_not_displayed=[ previous_changeset ] ) + def test_0045_install_base_repository( self ): + '''Verify installation of the repository with complex repository dependencies.''' + self.galaxy_logout() + self.galaxy_login( email=common.admin_email, username=common.admin_username ) + base_repository = test_db_util.get_repository_by_name_and_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_repository_by_name_and_owner( bwa_tool_repository_name, common.test_user_1_name ) + preview_strings_displayed = [ tool_repository.name, self.get_repository_tip( tool_repository ) ] + self.install_repository( bwa_base_repository_name, + common.test_user_1_name, + category_name, + install_tool_dependencies=True, + preview_strings_displayed=preview_strings_displayed, + post_submit_strings_displayed=[ base_repository.name, tool_repository.name, 'new' ], + includes_tools=True ) + def test_0050_verify_installed_repositories( self ): + '''Verify that the installed repositories are displayed properly.''' + base_repository = test_db_util.get_installed_repository_by_name_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_installed_repository_by_name_owner( bwa_tool_repository_name, common.test_user_1_name ) + strings_displayed = [ base_repository.name, base_repository.owner, base_repository.installed_changeset_revision ] + strings_displayed.extend( [ tool_repository.name, tool_repository.owner, tool_repository.installed_changeset_revision ] ) + strings_displayed.append( self.url.replace( 'http://', '' ) ) + self.display_galaxy_browse_repositories_page( strings_displayed=strings_displayed, strings_not_displayed=[] ) + checks = [ ( tool_repository, + [ tool_repository.name, tool_repository.owner, tool_repository.installed_changeset_revision ], + [ 'Missing tool dependencies' ] ), + ( base_repository, + [ base_repository.name, base_repository.owner, base_repository.installed_changeset_revision, tool_repository.name, + tool_repository.owner, tool_repository.installed_changeset_revision ], + [ 'Missing tool dependencies' ] ) ] + for repository, strings_displayed, strings_not_displayed in checks: + self.display_installed_repository_manage_page( repository, strings_displayed=strings_displayed, strings_not_displayed=strings_not_displayed ) + def test_0055_verify_complex_tool_dependency( self ): + '''Verify that the generated env.sh contains the right data.''' + base_repository = test_db_util.get_installed_repository_by_name_owner( bwa_base_repository_name, common.test_user_1_name ) + tool_repository = test_db_util.get_installed_repository_by_name_owner( bwa_tool_repository_name, common.test_user_1_name ) + env_sh_path = os.path.join( self.galaxy_tool_dependency_dir, + 'bwa', + '0.5.9', + base_repository.owner, + base_repository.name, + base_repository.installed_changeset_revision, + 'env.sh' ) + assert os.path.exists( env_sh_path ), 'env.sh was not generated in %s for this dependency.' % env_sh_path + contents = file( env_sh_path, 'r' ).read() + if tool_repository.installed_changeset_revision not in contents or tool_repository.name not in contents: + raise AssertionError( 'The env.sh file was not correctly generated. Contents: %s' % contents ) + diff -r 3de3a5a2d9b1f467ad5a7d855de84b2e2e7888a8 -r 596b4c29f84256767975caf9770d8c316d97386e test/tool_shed/functional/test_1110_install_repository_with_invalid_repository_dependency.py --- /dev/null +++ b/test/tool_shed/functional/test_1110_install_repository_with_invalid_repository_dependency.py @@ -0,0 +1,159 @@ +from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os +import tool_shed.base.test_db_util as test_db_util + +datatypes_repository_name = 'emboss_datatypes_0110' +datatypes_repository_description = "Galaxy applicable data formats used by Emboss tools." +datatypes_repository_long_description = "Galaxy applicable data formats used by Emboss tools. This repository contains no tools." + +emboss_repository_name = 'emboss_0110' +emboss_repository_description = 'Galaxy wrappers for Emboss version 5.0.0 tools' +emboss_repository_long_description = 'Galaxy wrappers for Emboss version 5.0.0 tools' + +category_name = 'Test 0110 Invalid Repository Dependencies' +category_desc = 'Test 0110 Invalid Repository Dependencies' +running_standalone = False + +class TestBasicRepositoryDependencies( ShedTwillTestCase ): + '''Testing emboss 5 with repository dependencies.''' + 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.admin_email, username=common.admin_username ) + admin_user = test_db_util.get_user( common.admin_email ) + assert admin_user is not None, 'Problem retrieving user with email %s from the database' % common.admin_email + admin_user_private_role = test_db_util.get_private_role( admin_user ) + def test_0005_create_category( self ): + """Create a category for this test suite""" + self.create_category( name=category_name, description=category_desc ) + def test_0010_create_emboss_datatypes_repository_and_upload_tarball( self ): + '''Create and populate the emboss_datatypes repository.''' + global running_standalone + self.logout() + self.login( email=common.test_user_1_email, username=common.test_user_1_name ) + category = test_db_util.get_category_by_name( category_name ) + repository = self.get_or_create_repository( name=datatypes_repository_name, + description=datatypes_repository_description, + long_description=datatypes_repository_long_description, + owner=common.test_user_1_name, + category_id=self.security.encode_id( category.id ), + strings_displayed=[] ) + if self.repository_is_new( repository ): + running_standalone = True + self.upload_file( repository, 'emboss/datatypes/datatypes_conf.xml', commit_message='Uploaded datatypes_conf.xml.' ) + def test_0015_verify_datatypes_in_datatypes_repository( self ): + '''Verify that the emboss_datatypes repository contains datatype entries.''' + repository = test_db_util.get_repository_by_name_and_owner( datatypes_repository_name, common.test_user_1_name ) + self.display_manage_repository_page( repository, strings_displayed=[ 'Datatypes', 'equicktandem', 'hennig86', 'vectorstrip' ] ) + def test_0020_create_emboss_5_repository_and_upload_files( self ): + '''Create and populate the emboss_5_0110 repository.''' + global running_standalone + if running_standalone: + category = test_db_util.get_category_by_name( category_name ) + 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', commit_message='Uploaded emboss_5.tar' ) + def test_0025_generate_repository_dependency_with_invalid_url( self ): + '''Generate a repository dependency for emboss 5 with an invalid URL.''' + global running_standalone + if running_standalone: + dependency_path = self.generate_temp_path( 'test_0110', additional_paths=[ 'simple' ] ) + xml_filename = self.get_filename( 'repository_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( 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 ) + url = 'http://http://this is not an url!' + name = repository.name + owner = repository.user.username + changeset_revision = self.get_repository_tip( repository ) + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=False, description='This is invalid.' ) + strings_displayed = [ 'Invalid tool shed <b>%s</b> defined for repository <b>%s</b>' % ( url, repository.name ) ] + self.upload_file( emboss_repository, + 'repository_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on emboss_datatypes_0110 with invalid url.', + strings_displayed=strings_displayed ) + def test_0030_generate_repository_dependency_with_invalid_name( self ): + '''Generate a repository dependency for emboss 5 with an invalid name.''' + global running_standalone + if running_standalone: + dependency_path = self.generate_temp_path( 'test_0110', additional_paths=[ 'simple' ] ) + xml_filename = self.get_filename( 'repository_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( 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 ) + url = self.url + name = '!?invalid?!' + owner = repository.user.username + changeset_revision = self.get_repository_tip( repository ) + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=False, description='This is invalid.' ) + strings_displayed = [ 'Invalid repository name <b>%s</b> defined.' % name ] + self.upload_file( emboss_repository, + 'repository_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on emboss_datatypes_0110 with invalid name.', + strings_displayed=strings_displayed ) + def test_0035_generate_repository_dependency_with_invalid_owner( self ): + '''Generate a repository dependency for emboss 5 with an invalid owner.''' + global running_standalone + if running_standalone: + dependency_path = self.generate_temp_path( 'test_0110', additional_paths=[ 'simple' ] ) + xml_filename = self.get_filename( 'repository_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( 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 ) + url = self.url + name = repository.name + owner = '!?invalid?!' + changeset_revision = self.get_repository_tip( repository ) + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=False, description='This is invalid.' ) + strings_displayed = [ 'Invalid owner <b>%s</b> defined for repository <b>%s</b>' % ( owner, repository.name ) ] + self.upload_file( emboss_repository, + 'repository_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on emboss_datatypes_0110 with invalid owner.', + strings_displayed=strings_displayed ) + def test_0040_generate_repository_dependency_with_invalid_changeset_revision( self ): + '''Generate a repository dependency for emboss 5 with an invalid changeset revision.''' + global running_standalone + if running_standalone: + dependency_path = self.generate_temp_path( 'test_0110', additional_paths=[ 'simple', 'invalid' ] ) + xml_filename = self.get_filename( 'repository_dependencies.xml', filepath=dependency_path ) + repository = test_db_util.get_repository_by_name_and_owner( 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 ) + url = self.url + name = repository.name + owner = repository.user.username + changeset_revision = '!?invalid?!' + self.generate_invalid_dependency_xml( xml_filename, url, name, owner, changeset_revision, complex=False, description='This is invalid.' ) + strings_displayed = [ 'Invalid changeset revision <b>%s</b> defined.' % changeset_revision ] + self.upload_file( emboss_repository, + 'repository_dependencies.xml', + valid_tools_only=False, + filepath=dependency_path, + commit_message='Uploaded dependency on emboss_datatypes_0110 with invalid changeset revision.', + strings_displayed=strings_displayed ) + def test_0045_install_repository_with_invalid_repository_dependency( self ): + '''Install the repository and verify that galaxy detects invalid repository dependencies.''' + self.galaxy_logout() + self.galaxy_login( email=common.admin_email, username=common.admin_username ) + repository = test_db_util.get_repository_by_name_and_owner( emboss_repository_name, common.test_user_1_name ) + preview_strings_displayed = [ repository.name, self.get_repository_tip( repository ), 'will be ignored' ] + self.install_repository( emboss_repository_name, + common.test_user_1_name, + category_name, + install_tool_dependencies=False, + install_repository_dependencies=True, + preview_strings_displayed=preview_strings_displayed, + post_submit_strings_displayed=[ repository.name, repository.name, 'new' ], + includes_tools=True ) + repository = test_db_util.get_installed_repository_by_name_owner( emboss_repository_name, common.test_user_1_name ) + self.display_installed_repository_manage_page( repository, strings_not_displayed=[ 'Repository dependencies' ] ) diff -r 3de3a5a2d9b1f467ad5a7d855de84b2e2e7888a8 -r 596b4c29f84256767975caf9770d8c316d97386e test/tool_shed/functional_tests.py --- a/test/tool_shed/functional_tests.py +++ b/test/tool_shed/functional_tests.py @@ -288,6 +288,7 @@ shed_tool_path = galaxy_shed_tool_path, template_path = "templates", tool_data_path = tool_data_path, + tool_dependency_dir = galaxy_tool_dependency_dir, tool_path = tool_path, tool_config_file = [ galaxy_tool_conf_file, galaxy_shed_tool_conf_file ], tool_sheds_config_file = galaxy_tool_sheds_conf_file, @@ -391,18 +392,18 @@ galaxyapp.shutdown() galaxyapp = None log.info( "Embedded galaxy application stopped" ) - if 'TOOL_SHED_TEST_NO_CLEANUP' not in os.environ: - try: - for dir in [ tool_shed_test_tmp_dir ]: - if os.path.exists( dir ): - log.info( "Cleaning up temporary files in %s" % dir ) - shutil.rmtree( dir ) - except: - pass - if success: - return 0 - else: - return 1 +# if 'TOOL_SHED_TEST_NO_CLEANUP' not in os.environ: +# try: +# for dir in [ tool_shed_test_tmp_dir ]: +# if os.path.exists( dir ): +# log.info( "Cleaning up temporary files in %s" % dir ) +# shutil.rmtree( dir ) +# except: +# pass +# if success: +# return 0 +# else: +# return 1 if __name__ == "__main__": sys.exit( main() ) 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.