mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #3190 from jmchilton/test_cleanup
Various Test Cleanups and Refactorings
This commit is contained in:
+2
-4
@@ -10,16 +10,14 @@ from .api_asserts import (
|
||||
)
|
||||
from .api_util import get_master_api_key, get_user_api_key
|
||||
from .interactor import GalaxyInteractorApi as BaseInteractor
|
||||
# TODO: We don't need all of TwillTestCase, strip down to a common super class
|
||||
# shared by API and Twill test cases.
|
||||
from .twilltestcase import TwillTestCase
|
||||
from .twilltestcase import FunctionalTestCase
|
||||
|
||||
TEST_USER = "user@bx.psu.edu"
|
||||
DEFAULT_OTHER_USER = "otheruser@bx.psu.edu" # A second user for API testing.
|
||||
|
||||
|
||||
# TODO: Allow these to point at existing Galaxy instances.
|
||||
class ApiTestCase( TwillTestCase ):
|
||||
class ApiTestCase( FunctionalTestCase ):
|
||||
|
||||
def setUp( self ):
|
||||
super( ApiTestCase, self ).setUp( )
|
||||
|
||||
@@ -46,11 +46,11 @@ def stage_data_in_history( galaxy_interactor, all_test_data, history, shed_tool_
|
||||
|
||||
class GalaxyInteractorApi( object ):
|
||||
|
||||
def __init__( self, twill_test_case, test_user=None ):
|
||||
self.twill_test_case = twill_test_case
|
||||
self.api_url = "%s/api" % twill_test_case.url.rstrip("/")
|
||||
self.master_api_key = twill_test_case.master_api_key
|
||||
self.api_key = self.__get_user_key( twill_test_case.user_api_key, twill_test_case.master_api_key, test_user=test_user )
|
||||
def __init__( self, functional_test_case, test_user=None ):
|
||||
self.functional_test_case = functional_test_case
|
||||
self.api_url = "%s/api" % functional_test_case.url.rstrip("/")
|
||||
self.master_api_key = functional_test_case.master_api_key
|
||||
self.api_key = self.__get_user_key( functional_test_case.user_api_key, functional_test_case.master_api_key, test_user=test_user )
|
||||
self.uploads = {}
|
||||
|
||||
def verify_output( self, history_id, jobs, output_data, output_testdef, shed_tool_id, maxseconds ):
|
||||
@@ -88,7 +88,7 @@ class GalaxyInteractorApi( object ):
|
||||
|
||||
def verify_output_dataset( self, history_id, hda_id, outfile, attributes, shed_tool_id ):
|
||||
fetcher = self.__dataset_fetcher( history_id )
|
||||
self.twill_test_case.verify_hid(
|
||||
self.functional_test_case.verify_hid(
|
||||
outfile,
|
||||
hda_id=hda_id,
|
||||
attributes=attributes,
|
||||
@@ -147,7 +147,7 @@ class GalaxyInteractorApi( object ):
|
||||
raise Exception( msg )
|
||||
|
||||
def wait_for_job( self, job_id, history_id, maxseconds ):
|
||||
self.twill_test_case.wait_for( lambda: not self.__job_ready( job_id, history_id ), maxseconds=maxseconds)
|
||||
self.functional_test_case.wait_for( lambda: not self.__job_ready( job_id, history_id ), maxseconds=maxseconds)
|
||||
|
||||
def get_job_stdio( self, job_id ):
|
||||
job_stdio = self.__get_job_stdio( job_id ).json()
|
||||
@@ -185,7 +185,7 @@ class GalaxyInteractorApi( object ):
|
||||
if composite_data:
|
||||
files = {}
|
||||
for i, composite_file in enumerate( composite_data ):
|
||||
file_name = self.twill_test_case.get_filename( composite_file.get( 'value' ), shed_tool_id=shed_tool_id )
|
||||
file_name = self.functional_test_case.get_filename( composite_file.get( 'value' ), shed_tool_id=shed_tool_id )
|
||||
files["files_%s|file_data" % i] = open( file_name, 'rb' )
|
||||
tool_input.update({
|
||||
# "files_%d|NAME" % i: name,
|
||||
@@ -195,7 +195,7 @@ class GalaxyInteractorApi( object ):
|
||||
})
|
||||
name = test_data[ 'name' ]
|
||||
else:
|
||||
file_name = self.twill_test_case.get_filename( fname, shed_tool_id=shed_tool_id )
|
||||
file_name = self.functional_test_case.get_filename( fname, shed_tool_id=shed_tool_id )
|
||||
name = test_data.get( 'name', None )
|
||||
if not name:
|
||||
name = os.path.basename( file_name )
|
||||
|
||||
+84
-1855
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,9 @@
|
||||
import time
|
||||
|
||||
import pyparsing # noqa: F401
|
||||
import twill.commands as tc
|
||||
from markupsafe import escape
|
||||
|
||||
import galaxy.model
|
||||
from base.test_db_util import (
|
||||
get_folder,
|
||||
@@ -30,6 +36,395 @@ regular_user1 = regular_user2 = regular_user3 = None
|
||||
|
||||
class TestLibraryFeatures( TwillTestCase ):
|
||||
|
||||
def add_folder( self, cntrller, library_id, folder_id, name='Folder One', description='This is Folder One' ):
|
||||
"""Create a new folder"""
|
||||
url = "%s/library_common/create_folder?cntrller=%s&library_id=%s&parent_id=%s" % ( self.url, cntrller, library_id, folder_id )
|
||||
self.visit_url( url )
|
||||
self.check_page_for_string( 'Create a new folder' )
|
||||
tc.fv( "1", "name", name )
|
||||
tc.fv( "1", "description", description )
|
||||
tc.submit( "new_folder_button" )
|
||||
check_str = escape( "The new folder named '%s' has been added to the data library." % name )
|
||||
self.check_page_for_string( check_str )
|
||||
|
||||
def add_template( self, cntrller, item_type, form_type, form_id, form_name,
|
||||
library_id=None, folder_id=None, ldda_id=None, request_type_id=None, sample_id=None ):
|
||||
"""
|
||||
Add a new template to an item - for library items, the template will ALWAYS BE SET TO INHERITABLE here. If you want to
|
||||
dis-inherit your template, call the manage_library_template_inheritance() below immediately after you call this
|
||||
method in your test code. Templates added to Requesttype objects are always inherited to samples.
|
||||
"""
|
||||
params = dict( cntrller=cntrller, item_type=item_type, form_type=form_type, library_id=library_id )
|
||||
url = "/library_common/add_template"
|
||||
if item_type == 'folder':
|
||||
params[ 'folder_id' ] = folder_id
|
||||
elif item_type == 'ldda':
|
||||
params[ 'ldda_id' ] = ldda_id
|
||||
self.visit_url( url, params )
|
||||
self.check_page_for_string( "Select a template for the" )
|
||||
self.refresh_form( "form_id", form_id )
|
||||
# For some unknown reason, twill barfs if the form number ( 1 ) is used in the following
|
||||
# rather than the form anme ( select_template ), so we have to use the form name.
|
||||
tc.fv( "select_template", "inheritable", '1' )
|
||||
tc.submit( "add_template_button" )
|
||||
self.check_page_for_string = 'A template based on the form "%s" has been added to this' % form_name
|
||||
|
||||
def browse_library( self, cntrller, library_id, show_deleted=False, strings_displayed=[], strings_not_displayed=[] ):
|
||||
self.visit_url( '%s/library_common/browse_library?cntrller=%s&id=%s&show_deleted=%s' % ( self.url, cntrller, library_id, str( show_deleted ) ) )
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
for check_str in strings_not_displayed:
|
||||
try:
|
||||
self.check_page_for_string( check_str )
|
||||
raise AssertionError( "String (%s) incorrectly displayed when browsing library." % check_str )
|
||||
except:
|
||||
pass
|
||||
|
||||
def create_library( self, name='Library One', description='This is Library One', synopsis='Synopsis for Library One' ):
|
||||
"""Create a new library"""
|
||||
self.visit_url( "%s/library_admin/create_library" % self.url )
|
||||
self.check_page_for_string( 'Create a new data library' )
|
||||
tc.fv( "1", "name", name )
|
||||
tc.fv( "1", "description", description )
|
||||
tc.fv( "1", "synopsis", synopsis )
|
||||
tc.submit( "create_library_button" )
|
||||
check_str = escape( "The new library named '%s' has been created" % name )
|
||||
self.check_page_for_string( check_str )
|
||||
|
||||
def create_form( self, name, description, form_type, field_type='TextField', form_layout_name='',
|
||||
num_fields=1, num_options=0, field_name='1_field_name', strings_displayed=[],
|
||||
strings_displayed_after_submit=[] ):
|
||||
"""Create a new form definition."""
|
||||
self.visit_url( "%s/forms/create_form_definition" % self.url )
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
tc.fv( "create_form_definition", "name", name )
|
||||
tc.fv( "create_form_definition", "description", description )
|
||||
tc.fv( "create_form_definition", "form_type_select_field", form_type )
|
||||
tc.submit( "create_form_button" )
|
||||
if form_type == "Sequencing Sample Form":
|
||||
tc.submit( "add_layout_grid" )
|
||||
tc.fv( "edit_form_definition", "grid_layout0", form_layout_name )
|
||||
# if not adding any fields at this time, remove the default empty field
|
||||
if num_fields == 0:
|
||||
tc.submit( "remove_button" )
|
||||
# Add fields to the new form definition
|
||||
for index1 in range( num_fields ):
|
||||
field_label = 'field_label_%i' % index1
|
||||
field_contents = field_type
|
||||
field_help_name = 'field_helptext_%i' % index1
|
||||
field_help_contents = 'Field %i help' % index1
|
||||
field_default = 'field_default_0'
|
||||
field_default_contents = '%s default contents' % form_type
|
||||
tc.fv( "edit_form_definition", field_label, field_contents )
|
||||
tc.fv( "edit_form_definition", field_help_name, field_help_contents )
|
||||
if field_type == 'SelectField':
|
||||
# SelectField field_type requires a refresh_on_change
|
||||
self.refresh_form( 'field_type_0', field_type )
|
||||
# Add options so our select list is functional
|
||||
if num_options == 0:
|
||||
# Default to 2 options
|
||||
num_options = 2
|
||||
for index2 in range( 1, num_options + 1 ):
|
||||
tc.submit( "addoption_0" )
|
||||
# Add contents to the new options fields
|
||||
for index2 in range( num_options ):
|
||||
option_field_name = 'field_0_option_%i' % index2
|
||||
option_field_value = 'Option%i' % index2
|
||||
tc.fv( "edit_form_definition", option_field_name, option_field_value )
|
||||
else:
|
||||
tc.fv( "edit_form_definition", "field_type_0", field_type )
|
||||
tc.fv( "edit_form_definition", 'field_name_0', field_name )
|
||||
tc.fv( "edit_form_definition", field_default, field_default_contents )
|
||||
# All done... now save
|
||||
tc.submit( "save_changes_button" )
|
||||
for check_str in strings_displayed_after_submit:
|
||||
self.check_page_for_string( check_str )
|
||||
|
||||
def delete_library_item( self, cntrller, library_id, item_id, item_name, item_type='library_dataset' ):
|
||||
"""Mark a library item as deleted"""
|
||||
params = dict( cntrller=cntrller, library_id=library_id, item_id=item_id, item_type=item_type )
|
||||
self.visit_url( "/library_common/delete_library_item", params )
|
||||
if item_type == 'library_dataset':
|
||||
item_desc = 'Dataset'
|
||||
else:
|
||||
item_desc = item_type.capitalize()
|
||||
check_str = "marked deleted"
|
||||
self.check_for_strings( strings_displayed=[ item_desc, check_str ] )
|
||||
|
||||
def edit_template( self, cntrller, item_type, form_type, library_id, field_type, field_label_1, field_helptext_1, field_default_1,
|
||||
folder_id='', ldda_id='', action='add_field' ):
|
||||
"""Edit the form fields defining a library template"""
|
||||
params = dict( cntrller=cntrller, item_type=item_type, form_type=form_type, library_id=library_id )
|
||||
self.visit_url( "/library_common/edit_template", params=params )
|
||||
self.check_page_for_string( "Edit form definition" )
|
||||
if action == 'add_field':
|
||||
tc.submit( "add_field_button" )
|
||||
tc.fv( "edit_form", "field_label_1", field_label_1 )
|
||||
tc.fv( "edit_form", "field_helptext_1", field_helptext_1 )
|
||||
if field_type == 'SelectField':
|
||||
# Performs a refresh_on_change in this case
|
||||
self.refresh_form( "field_type_1", field_type )
|
||||
else:
|
||||
tc.fv( "edit_form", "field_type_1", field_type )
|
||||
tc.fv( "edit_form", "field_default_1", field_default_1 )
|
||||
tc.submit( 'save_changes_button' )
|
||||
self.check_page_for_string( "The template for this data library has been updated with your changes." )
|
||||
|
||||
def folder_info( self, cntrller, folder_id, library_id, name='', new_name='', description='', template_refresh_field_name='1_field_name',
|
||||
template_refresh_field_contents='', template_fields=[], strings_displayed=[], strings_not_displayed=[],
|
||||
strings_displayed_after_submit=[], strings_not_displayed_after_submit=[] ):
|
||||
"""Add information to a library using an existing template with 2 elements"""
|
||||
self.visit_url( "%s/library_common/folder_info?cntrller=%s&id=%s&library_id=%s" %
|
||||
( self.url, cntrller, folder_id, library_id ) )
|
||||
if name and new_name and description:
|
||||
tc.fv( '1', "name", new_name )
|
||||
tc.fv( '1', "description", description )
|
||||
tc.submit( 'rename_folder_button' )
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
for check_str in strings_not_displayed:
|
||||
try:
|
||||
self.check_page_for_string( check_str )
|
||||
raise AssertionError( "String (%s) incorrectly displayed." % check_str )
|
||||
except:
|
||||
pass
|
||||
if template_refresh_field_contents:
|
||||
# A template containing an AddressField is displayed on the form, so we need to refresh the form
|
||||
# with the received template_refresh_field_contents. There are 2 forms on the folder_info page
|
||||
# when in edit mode, and the 2nd one is the one we want.
|
||||
self.refresh_form( template_refresh_field_name, template_refresh_field_contents, form_no=2 )
|
||||
if template_fields:
|
||||
# We have an information template associated with the folder, so
|
||||
# there are 2 forms on this page and the template is the 2nd form
|
||||
for field_name, field_value in template_fields:
|
||||
tc.fv( "edit_info", field_name, field_value )
|
||||
tc.submit( 'edit_info_button' )
|
||||
for check_str in strings_displayed_after_submit:
|
||||
self.check_page_for_string( check_str )
|
||||
for check_str in strings_not_displayed_after_submit:
|
||||
try:
|
||||
self.check_page_for_string( check_str )
|
||||
raise AssertionError( "String (%s) incorrectly displayed." % check_str )
|
||||
except:
|
||||
pass
|
||||
|
||||
def ldda_edit_info( self, cntrller, library_id, folder_id, ldda_id, ldda_name, new_ldda_name='', template_refresh_field_name='1_field_name',
|
||||
template_refresh_field_contents='', template_fields=[], strings_displayed=[], strings_not_displayed=[] ):
|
||||
"""Edit library_dataset_dataset_association information, optionally template element information"""
|
||||
self.visit_url( "%s/library_common/ldda_edit_info?cntrller=%s&library_id=%s&folder_id=%s&id=%s" %
|
||||
( self.url, cntrller, library_id, folder_id, ldda_id ) )
|
||||
check_str = 'Edit attributes of %s' % ldda_name
|
||||
self.check_page_for_string( check_str )
|
||||
if new_ldda_name:
|
||||
tc.fv( '1', 'name', new_ldda_name )
|
||||
tc.submit( 'save' )
|
||||
check_str = escape( "Attributes updated for library dataset '%s'." % new_ldda_name )
|
||||
self.check_page_for_string( check_str )
|
||||
if template_refresh_field_contents:
|
||||
# A template containing an AddressField is displayed on the upload form, so we need to refresh the form
|
||||
# with the received template_refresh_field_contents. There are 4 forms on this page, and the template is
|
||||
# contained in the 4th form named "edit_info".
|
||||
self.refresh_form( template_refresh_field_name, template_refresh_field_contents, form_no=4 )
|
||||
if template_fields:
|
||||
# We have an information template associated with the folder, so
|
||||
# there are 2 forms on this page and the template is the 2nd form
|
||||
for field_name, field_value in template_fields:
|
||||
tc.fv( "edit_info", field_name, field_value )
|
||||
tc.submit( 'edit_info_button' )
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
for check_str in strings_not_displayed:
|
||||
try:
|
||||
self.check_page_for_string( check_str )
|
||||
raise AssertionError( "String (%s) should not have been displayed on ldda Edit Attributes page." % check_str )
|
||||
except:
|
||||
pass
|
||||
|
||||
def library_info( self, cntrller, library_id, library_name='', new_name='', new_description='', new_synopsis='',
|
||||
template_fields=[], strings_displayed=[] ):
|
||||
"""Edit information about a library, optionally using an existing template with up to 2 elements"""
|
||||
self.visit_url( "%s/library_common/library_info?cntrller=%s&id=%s" % ( self.url, cntrller, library_id ) )
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
if new_name and new_description and new_synopsis:
|
||||
tc.fv( '1', 'name', new_name )
|
||||
tc.fv( '1', 'description', new_description )
|
||||
tc.fv( '1', 'synopsis', new_synopsis )
|
||||
tc.submit( 'library_info_button' )
|
||||
self.check_page_for_string( "Information updated for library" )
|
||||
if template_fields:
|
||||
for field_name, field_value in template_fields:
|
||||
# The 2nd form on the page contains the template, and the form is named edit_info.
|
||||
# Set the template field value
|
||||
tc.fv( "edit_info", field_name, field_value )
|
||||
tc.submit( 'edit_info_button' )
|
||||
|
||||
def library_wait( self, library_id, cntrller='library_admin', maxiter=90 ):
|
||||
"""Waits for the tools to finish"""
|
||||
count = 0
|
||||
sleep_amount = 1
|
||||
while count < maxiter:
|
||||
count += 1
|
||||
self.visit_url( "%s/library_common/browse_library?cntrller=%s&id=%s" % ( self.url, cntrller, library_id ) )
|
||||
page = tc.browser.get_html()
|
||||
if page.find( '<!-- running: do not change this comment, used by TwillTestCase.library_wait -->' ) > -1:
|
||||
time.sleep( sleep_amount )
|
||||
sleep_amount += 1
|
||||
else:
|
||||
break
|
||||
self.assertNotEqual(count, maxiter)
|
||||
|
||||
def manage_library_template_inheritance( self, cntrller, item_type, library_id, folder_id=None, ldda_id=None, inheritable=True ):
|
||||
# If inheritable is True, the item is currently inheritable.
|
||||
if item_type == 'library':
|
||||
url = "%s/library_common/manage_template_inheritance?cntrller=%s&item_type=%s&library_id=%s" % \
|
||||
( self.url, cntrller, item_type, library_id )
|
||||
elif item_type == 'folder':
|
||||
url = "%s/library_common/manage_template_inheritance?cntrller=%s&item_type=%s&library_id=%s&folder_id=%s" % \
|
||||
( self.url, cntrller, item_type, library_id, folder_id )
|
||||
elif item_type == 'ldda':
|
||||
url = "%s/library_common/manage_template_inheritance?cntrller=%s&item_type=%s&library_id=%s&folder_id=%s&ldda_id=%s" % \
|
||||
( self.url, cntrller, item_type, library_id, folder_id, ldda_id )
|
||||
self.visit_url( url )
|
||||
if inheritable:
|
||||
self.check_page_for_string = 'will no longer be inherited to contained folders and datasets'
|
||||
else:
|
||||
self.check_page_for_string = 'will now be inherited to contained folders and datasets'
|
||||
|
||||
def mark_form_deleted( self, form_id ):
|
||||
"""Mark a form_definition as deleted"""
|
||||
url = "%s/forms/delete_form_definition?id=%s" % ( self.url, form_id )
|
||||
self.visit_url( url )
|
||||
check_str = "1 forms have been deleted."
|
||||
self.check_page_for_string( check_str )
|
||||
|
||||
def purge_library( self, library_id, library_name ):
|
||||
"""Purge a library"""
|
||||
params = dict( id=library_id )
|
||||
self.visit_url( "/library_admin/purge_library", params )
|
||||
check_str = "Library '%s' and all of its contents have been purged" % library_name
|
||||
self.check_page_for_string( check_str )
|
||||
|
||||
def upload_library_dataset( self, cntrller, library_id, folder_id, filename='', server_dir='', replace_id='',
|
||||
upload_option='upload_file', file_type='auto', dbkey='hg18', space_to_tab='',
|
||||
link_data_only='copy_files', preserve_dirs='Yes', filesystem_paths='', roles=[],
|
||||
ldda_message='', hda_ids='', template_refresh_field_name='1_field_name',
|
||||
template_refresh_field_contents='', template_fields=[], show_deleted='False', strings_displayed=[] ):
|
||||
"""Add datasets to library using any upload_option"""
|
||||
# NOTE: due to the library_wait() method call at the end of this method, no tests should be done
|
||||
# for strings_displayed_after_submit.
|
||||
params = dict( cntrller=cntrller, library_id=library_id, folder_id=folder_id )
|
||||
url = "/library_common/upload_library_dataset"
|
||||
if replace_id:
|
||||
# If we're uploading a new version of a library dataset, we have to include the replace_id param in the
|
||||
# request because the form field named replace_id will not be displayed on the upload form if we dont.
|
||||
params[ 'replace_id' ] = replace_id
|
||||
self.visit_url( url, params=params )
|
||||
if template_refresh_field_contents:
|
||||
# A template containing an AddressField is displayed on the upload form, so we need to refresh the form
|
||||
# with the received template_refresh_field_contents.
|
||||
self.refresh_form( template_refresh_field_name, template_refresh_field_contents )
|
||||
for tup in template_fields:
|
||||
tc.fv( "1", tup[0], tup[1] )
|
||||
tc.fv( "upload_library_dataset", "library_id", library_id )
|
||||
tc.fv( "upload_library_dataset", "folder_id", folder_id )
|
||||
tc.fv( "upload_library_dataset", "show_deleted", show_deleted )
|
||||
tc.fv( "upload_library_dataset", "ldda_message", ldda_message )
|
||||
tc.fv( "upload_library_dataset", "file_type", file_type )
|
||||
tc.fv( "upload_library_dataset", "dbkey", dbkey )
|
||||
if space_to_tab:
|
||||
tc.fv( "upload_library_dataset", "space_to_tab", space_to_tab )
|
||||
for role_id in roles:
|
||||
tc.fv( "upload_library_dataset", "roles", role_id )
|
||||
# Refresh the form by selecting the upload_option - we do this here to ensure
|
||||
# all previously entered form contents are retained.
|
||||
self.refresh_form( 'upload_option', upload_option )
|
||||
if upload_option == 'import_from_history':
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
if hda_ids:
|
||||
# Twill cannot handle multi-checkboxes, so the form can only have 1 hda_ids checkbox
|
||||
try:
|
||||
tc.fv( "add_history_datasets_to_library", "hda_ids", hda_ids )
|
||||
except:
|
||||
tc.fv( "add_history_datasets_to_library", "hda_ids", '1' )
|
||||
tc.submit( 'add_history_datasets_to_library_button' )
|
||||
else:
|
||||
if upload_option in [ 'upload_paths', 'upload_directory' ]:
|
||||
tc.fv( "upload_library_dataset", "link_data_only", link_data_only )
|
||||
if upload_option == 'upload_paths':
|
||||
tc.fv( "upload_library_dataset", "filesystem_paths", filesystem_paths )
|
||||
if upload_option == 'upload_directory' and server_dir:
|
||||
tc.fv( "upload_library_dataset", "server_dir", server_dir )
|
||||
if upload_option == 'upload_file':
|
||||
if filename:
|
||||
filename = self.get_filename( filename )
|
||||
tc.formfile( "upload_library_dataset", "files_0|file_data", filename )
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
tc.submit( "runtool_btn" )
|
||||
# Give the files some time to finish uploading
|
||||
self.library_wait( library_id )
|
||||
|
||||
def view_form( self, id, form_type='', form_name='', form_desc='', form_layout_name='', field_dicts=[] ):
|
||||
'''View form details'''
|
||||
self.visit_url( "%s/forms/view_latest_form_definition?id=%s" % ( self.url, id ) )
|
||||
# self.check_page_for_string( form_type )
|
||||
self.check_page_for_string( form_name )
|
||||
# self.check_page_for_string( form_desc )
|
||||
self.check_page_for_string( form_layout_name )
|
||||
for i, field_dict in enumerate( field_dicts ):
|
||||
self.check_page_for_string( field_dict[ 'label' ] )
|
||||
self.check_page_for_string( field_dict[ 'desc' ] )
|
||||
self.check_page_for_string( field_dict[ 'type' ] )
|
||||
if field_dict[ 'type' ].lower() == 'selectfield':
|
||||
for option_index, option in enumerate( field_dict[ 'selectlist' ] ):
|
||||
self.check_page_for_string( option )
|
||||
|
||||
def upload_file( self, filename, ftype='auto', dbkey='unspecified (?)', space_to_tab=False, metadata=None, composite_data=None, name=None, wait=True ):
|
||||
"""
|
||||
Uploads a file. If shed_tool_id has a value, we're testing tools migrated from the distribution to the tool shed,
|
||||
so the tool-data directory of test data files is contained in the installed tool shed repository.
|
||||
"""
|
||||
self.visit_url( "%s/tool_runner?tool_id=upload1" % self.url )
|
||||
try:
|
||||
self.refresh_form( "file_type", ftype ) # Refresh, to support composite files
|
||||
tc.fv( "tool_form", "dbkey", dbkey )
|
||||
if metadata:
|
||||
for elem in metadata:
|
||||
tc.fv( "tool_form", "files_metadata|%s" % elem.get( 'name' ), elem.get( 'value' ) )
|
||||
if composite_data:
|
||||
for i, composite_file in enumerate( composite_data ):
|
||||
filename = self.get_filename( composite_file.get( 'value' ) )
|
||||
tc.formfile( "tool_form", "files_%i|file_data" % i, filename )
|
||||
tc.fv( "tool_form", "files_%i|space_to_tab" % i, composite_file.get( 'space_to_tab', False ) )
|
||||
else:
|
||||
filename = self.get_filename( filename )
|
||||
tc.formfile( "tool_form", "file_data", filename )
|
||||
tc.fv( "tool_form", "space_to_tab", space_to_tab )
|
||||
if name:
|
||||
# NAME is a hidden form element, so the following prop must
|
||||
# set to use it.
|
||||
tc.config("readonly_controls_writeable", 1)
|
||||
tc.fv( "tool_form", "NAME", name )
|
||||
tc.submit( "runtool_btn" )
|
||||
except AssertionError as err:
|
||||
errmsg = "Uploading file resulted in the following exception. Make sure the file (%s) exists. " % filename
|
||||
errmsg += str( err )
|
||||
raise AssertionError( errmsg )
|
||||
if not wait:
|
||||
return
|
||||
# Make sure every history item has a valid hid
|
||||
hids = self.get_hids_in_history( self.get_latest_history()[ 'id' ] )
|
||||
for hid in hids:
|
||||
try:
|
||||
int( hid )
|
||||
except:
|
||||
raise AssertionError( "Invalid hid (%s) created when uploading file %s" % ( hid, filename ) )
|
||||
# Wait for upload processing to finish (TODO: this should be done in each test case instead)
|
||||
self.wait()
|
||||
|
||||
def test_000_initiate_users( self ):
|
||||
"""Ensuring all required user accounts exist"""
|
||||
self.login( email='test1@bx.psu.edu', username='regular-user1' )
|
||||
|
||||
@@ -44,13 +44,11 @@ class ShedTwillTestCase( TwillTestCase ):
|
||||
self.galaxy_url = "http://%s:%s" % ( self.galaxy_host, self.galaxy_port )
|
||||
self.shed_tool_data_table_conf = os.environ.get( 'TOOL_SHED_TEST_TOOL_DATA_TABLE_CONF' )
|
||||
self.file_dir = os.environ.get( 'TOOL_SHED_TEST_FILE_DIR', None )
|
||||
self.tool_shed_test_file = None
|
||||
self.tool_data_path = os.environ.get( 'GALAXY_TEST_TOOL_DATA_PATH' )
|
||||
self.shed_tool_conf = os.environ.get( 'GALAXY_TEST_SHED_TOOL_CONF' )
|
||||
self.test_db_util = test_db_util
|
||||
# TODO: Figure out a way to alter these attributes during tests.
|
||||
self.galaxy_tool_dependency_dir = os.environ.get( 'GALAXY_TEST_TOOL_DEPENDENCY_DIR' )
|
||||
self.shed_tools_dict = {}
|
||||
|
||||
def add_repository_review_component( self, **kwd ):
|
||||
url = '/repository_review/create_component?operation=create'
|
||||
|
||||
Reference in New Issue
Block a user