mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Move the upload_option (ie., file, directory, filesystem paths, import from history) into a select list on the data library upload form. Selecting an upload_option now performs a refresh_on_change on the upload form so that any form contents entered before selecting the option are now retained. Improvements and bug fixes were made throughout the pieces of the framework that support this.
Major improvements and very significant code cleanup to the entire functional test framework was done in this change set as well.
This commit is contained in:
@@ -785,7 +785,7 @@ class HistoryDatasetAssociation( DatasetInstance ):
|
||||
hda.set_peek()
|
||||
object_session( self ).flush()
|
||||
return hda
|
||||
def to_library_dataset_dataset_association( self, target_folder, replace_dataset=None, parent_id=None, user=None ):
|
||||
def to_library_dataset_dataset_association( self, trans, target_folder, replace_dataset=None, parent_id=None, user=None, roles=[], ldda_message='' ):
|
||||
if replace_dataset:
|
||||
# The replace_dataset param ( when not None ) refers to a LibraryDataset that is being replaced with a new version.
|
||||
library_dataset = replace_dataset
|
||||
@@ -796,6 +796,7 @@ class HistoryDatasetAssociation( DatasetInstance ):
|
||||
object_session( self ).add( library_dataset )
|
||||
object_session( self ).flush()
|
||||
if not user:
|
||||
# This should never happen since users must be authenticated to upload to a data library
|
||||
user = self.history.user
|
||||
ldda = LibraryDatasetDatasetAssociation( name=self.name,
|
||||
info=self.info,
|
||||
@@ -812,9 +813,15 @@ class HistoryDatasetAssociation( DatasetInstance ):
|
||||
user=user )
|
||||
object_session( self ).add( ldda )
|
||||
object_session( self ).flush()
|
||||
# Permissions must be the same on the LibraryDatasetDatasetAssociation and the associated LibraryDataset
|
||||
# If roles were selected on the upload form, restrict access to the Dataset to those roles
|
||||
for role in roles:
|
||||
dp = trans.model.DatasetPermissions( trans.app.security_agent.permitted_actions.DATASET_ACCESS.action, ldda.dataset, role )
|
||||
trans.sa_session.add( dp )
|
||||
trans.sa_session.flush()
|
||||
# Must set metadata after ldda flushed, as MetadataFiles require ldda.id
|
||||
ldda.metadata = self.metadata
|
||||
if ldda_message:
|
||||
ldda.message = ldda_message
|
||||
if not replace_dataset:
|
||||
target_folder.add_library_dataset( library_dataset, genome_build=ldda.dbkey )
|
||||
object_session( self ).add( target_folder )
|
||||
@@ -823,7 +830,8 @@ class HistoryDatasetAssociation( DatasetInstance ):
|
||||
object_session( self ).add( library_dataset )
|
||||
object_session( self ).flush()
|
||||
for child in self.children:
|
||||
child_copy = child.to_library_dataset_dataset_association( target_folder=target_folder,
|
||||
child_copy = child.to_library_dataset_dataset_association( trans,
|
||||
target_folder=target_folder,
|
||||
replace_dataset=replace_dataset,
|
||||
parent_id=ldda.id,
|
||||
user=ldda.user )
|
||||
@@ -951,8 +959,7 @@ class LibraryFolder( object ):
|
||||
# See if we have any associated templates. The get_contents
|
||||
# param is passed by callers that are inheriting a template - these
|
||||
# are usually new library datsets for which we want to include template
|
||||
# fields on the upload form, but not necessarily the contents of the
|
||||
# inherited template saved for the parent.
|
||||
# fields on the upload form.
|
||||
info_association, inherited = self.get_info_association()
|
||||
if info_association:
|
||||
if inherited:
|
||||
@@ -1037,6 +1044,10 @@ class LibraryFolder( object ):
|
||||
|
||||
class LibraryDataset( object ):
|
||||
# This class acts as a proxy to the currently selected LDDA
|
||||
upload_options = [ ( 'upload_file', 'Upload files' ),
|
||||
( 'upload_directory', 'Upload directory of files' ),
|
||||
( 'upload_paths', 'Upload files from filesystem paths' ),
|
||||
( 'import_from_history', 'Import datasets from your current history' ) ]
|
||||
def __init__( self, folder=None, order_id=None, name=None, info=None, library_dataset_dataset_association=None, **kwd ):
|
||||
self.folder = folder
|
||||
self.order_id = order_id
|
||||
|
||||
@@ -40,7 +40,7 @@ def handle_library_params( trans, params, folder_id, replace_dataset=None ):
|
||||
# manipulated here. The receivd params should be the original kwd from the initial request.
|
||||
library_bunch = util.bunch.Bunch()
|
||||
library_bunch.replace_dataset = replace_dataset
|
||||
library_bunch.message = params.get( 'message', '' )
|
||||
library_bunch.message = params.get( 'ldda_message', '' )
|
||||
# See if we have any template field contents
|
||||
library_bunch.template_field_contents = []
|
||||
template_id = params.get( 'template_id', None )
|
||||
|
||||
@@ -269,22 +269,20 @@ class UsesFormDefinitionWidgets:
|
||||
return True
|
||||
return False
|
||||
def clean_field_contents( self, widgets, **kwd ):
|
||||
params = util.Params( kwd )
|
||||
field_contents = []
|
||||
for index in range( len( widgets ) ):
|
||||
widget = widgets[ index ][ 'widget' ]
|
||||
field_value = params.get( 'field_%i' % ( index ), '' )
|
||||
for index, widget_dict in enumerate( widgets ):
|
||||
widget = widget_dict[ 'widget' ]
|
||||
value = kwd.get( widget.name, '' )
|
||||
if isinstance( widget, CheckboxField ):
|
||||
# CheckboxField values are lists if the checkbox is checked
|
||||
field_value = str( widget.is_checked( field_value ) ).lower()
|
||||
value = str( widget.is_checked( value ) ).lower()
|
||||
elif isinstance( widget, AddressField ):
|
||||
# If the address was new, is has already been saved and widget.value is the new address.id
|
||||
field_value = widget.value
|
||||
field_contents.append( util.restore_text( field_value ) )
|
||||
value = widget.value
|
||||
field_contents.append( util.restore_text( value ) )
|
||||
return field_contents
|
||||
def field_param_values_ok( self, index, widget_type, **kwd ):
|
||||
# Make sure required fields have contents, etc
|
||||
# TODO: Add support for other field types ( e.g., WorkflowField, etc )
|
||||
params = util.Params( kwd )
|
||||
if widget_type == 'AddressField':
|
||||
if not util.restore_text( params.get( 'field_%i_short_desc' % index, '' ) ) \
|
||||
@@ -299,7 +297,6 @@ class UsesFormDefinitionWidgets:
|
||||
return True
|
||||
def save_widget_field( self, trans, field_obj, index, **kwd ):
|
||||
# Save a form_builder field object
|
||||
# TODO: Add support for other field types ( e.g., WorkflowField, etc )
|
||||
params = util.Params( kwd )
|
||||
if isinstance( field_obj, trans.model.UserAddress ):
|
||||
field_obj.desc = util.restore_text( params.get( 'field_%i_short_desc' % index, '' ) )
|
||||
@@ -313,6 +310,55 @@ class UsesFormDefinitionWidgets:
|
||||
field_obj.phone = util.restore_text( params.get( 'field_%i_phone' % index, '' ) )
|
||||
trans.sa_session.add( field_obj )
|
||||
trans.sa_session.flush()
|
||||
def populate_widgets_from_kwd( self, trans, widgets, **kwd ):
|
||||
# A form submitted via refresh_on_change requires us to populate the widgets with the contents of
|
||||
# the form fields the user may have entered so that when the form refreshes the contents are retained.
|
||||
params = util.Params( kwd )
|
||||
populated_widgets = []
|
||||
for widget_dict in widgets:
|
||||
widget = widget_dict[ 'widget' ]
|
||||
if params.get( widget.name, False ):
|
||||
# The form included a field whose contents should be used to set the
|
||||
# value of the current widget (widget.name is field_0, field_1, etc).
|
||||
if isinstance( widget, AddressField ):
|
||||
value = util.restore_text( params.get( widget.name, '' ) )
|
||||
if value == 'new':
|
||||
# Adding a new address
|
||||
widget.value = value
|
||||
widget_dict[ 'widget' ] = widget
|
||||
elif value == 'none':
|
||||
widget.value = ''
|
||||
widget_dict[ 'widget' ] = widget
|
||||
else:
|
||||
# An existing address object was selected
|
||||
address_obj = trans.sa_session.query( trans.app.model.UserAddress ).get( int( value ) )
|
||||
widget_dict[ 'widget' ] = address_obj
|
||||
# Populate the AddressField params with the form field contents
|
||||
widget_params_dict = {}
|
||||
for field_name, label, help_text in widget.fields():
|
||||
form_param_name = '%s_%s' % ( widget.name, field_name )
|
||||
widget_params_dict[ form_param_name ] = util.restore_text( params.get( form_param_name, '' ) )
|
||||
widget.params = widget_params_dict
|
||||
elif isinstance( widget, CheckboxField ):
|
||||
# Check the value from kwd since util.Params would have
|
||||
# stringify'd the list if the checkbox is checked.
|
||||
value = kwd.get( widget.name, '' )
|
||||
if CheckboxField.is_checked( value ):
|
||||
widget.value = 'true'
|
||||
widget_dict[ 'widget' ] = widget
|
||||
elif isinstance( widget, SelectField ):
|
||||
# Ensure the selected option remains selected.
|
||||
value = util.restore_text( params.get( widget.name, '' ) )
|
||||
processed_options = []
|
||||
for option_label, option_value, option_selected in widget.options:
|
||||
selected = value == option_value
|
||||
processed_options.append( ( option_label, option_value, selected ) )
|
||||
widget.options = processed_options
|
||||
else:
|
||||
widget.value = util.restore_text( params.get( widget.name, '' ) )
|
||||
widget_dict[ 'widget' ] = widget
|
||||
populated_widgets.append( widget_dict )
|
||||
return populated_widgets
|
||||
|
||||
class Sharable:
|
||||
""" Mixin for a controller that manages an item that can be shared. """
|
||||
|
||||
@@ -695,17 +695,24 @@ class LibraryCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
params = util.Params( kwd )
|
||||
message = util.restore_text( params.get( 'message', '' ) )
|
||||
status = params.get( 'status', 'done' )
|
||||
ldda_message = util.restore_text( params.get( 'ldda_message', '' ) )
|
||||
deleted = util.string_as_bool( params.get( 'deleted', False ) )
|
||||
show_deleted = util.string_as_bool( params.get( 'show_deleted', False ) )
|
||||
use_panels = util.string_as_bool( params.get( 'use_panels', False ) )
|
||||
dbkey = params.get( 'dbkey', '?' )
|
||||
replace_id = params.get( 'replace_id', None )
|
||||
replace_dataset = None
|
||||
upload_option = params.get( 'upload_option', 'upload_file' )
|
||||
if params.get( 'files_0|space_to_tab', False ):
|
||||
space_to_tab = params.get( 'files_0|space_to_tab', '' )
|
||||
else:
|
||||
space_to_tab = params.get( 'space_to_tab', '' )
|
||||
link_data_only = params.get( 'link_data_only', '' )
|
||||
dbkey = params.get( 'dbkey', '?' )
|
||||
if isinstance( dbkey, list ):
|
||||
last_used_build = dbkey[0]
|
||||
else:
|
||||
last_used_build = dbkey
|
||||
roles = params.get( 'roles', '' )
|
||||
is_admin = trans.user_is_admin() and cntrller in ( 'library_admin', 'api' )
|
||||
current_user_roles = trans.get_current_user_roles()
|
||||
if replace_id not in [ None, 'None' ]:
|
||||
@@ -725,24 +732,20 @@ class LibraryCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
# Don't allow multiple datasets to be uploaded when replacing a dataset with a new version
|
||||
upload_option = 'upload_file'
|
||||
else:
|
||||
try:
|
||||
folder = trans.sa_session.query( trans.app.model.LibraryFolder ).get( trans.security.decode_id( folder_id ) )
|
||||
except:
|
||||
folder = None
|
||||
folder = trans.sa_session.query( trans.app.model.LibraryFolder ).get( trans.security.decode_id( folder_id ) )
|
||||
self._check_access( trans, cntrller, is_admin, folder, current_user_roles, use_panels, library_id, show_deleted )
|
||||
self._check_add( trans, cntrller, is_admin, folder, current_user_roles, use_panels, library_id, show_deleted )
|
||||
library = folder.parent_library
|
||||
if folder and last_used_build in [ 'None', None, '?' ]:
|
||||
last_used_build = folder.genome_build
|
||||
if params.get( 'runtool_btn', False ) or params.get( 'ajax_upload', False ) or cntrller == 'api':
|
||||
# Check to see if the user selected roles to associate with the DATASET_ACCESS permission
|
||||
# on the dataset that would cause accessibility issues.
|
||||
roles = params.get( 'roles', False )
|
||||
error = False
|
||||
if upload_option == 'upload_paths' and not trans.app.config.allow_library_path_paste:
|
||||
error = True
|
||||
message = '"allow_library_path_paste" is not defined in the Galaxy configuration file'
|
||||
elif roles:
|
||||
# Check to see if the user selected roles to associate with the DATASET_ACCESS permission
|
||||
# on the dataset that would cause accessibility issues.
|
||||
vars = dict( DATASET_ACCESS_in=roles )
|
||||
permissions, in_roles, error, message = \
|
||||
trans.app.security_agent.derive_roles_from_access( trans, library.id, cntrller, library=True, **vars )
|
||||
@@ -780,14 +783,14 @@ class LibraryCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
widget.value = str( address.id )
|
||||
widget_dict[ 'widget' ] = widget
|
||||
processed_widgets.append( widget_dict )
|
||||
# FIXME: ( hack ) It is now critical to update the value of 'field_%i', replacing the string
|
||||
# It is now critical to update the value of 'field_%i', replacing the string
|
||||
# 'new' with the new address id. This is necessary because the upload_dataset()
|
||||
# method below calls the handle_library_params() method, which does not parse the
|
||||
# widget fields, it instead pulls form values from kwd. See the FIXME comments in the
|
||||
# handle_library_params() method, and the CheckboxField code in the next conditional.
|
||||
kwd[ 'field_%i' % index ] = str( address.id )
|
||||
else:
|
||||
# The invalid address won't be saved, but we cannot dispaly error
|
||||
# The invalid address won't be saved, but we cannot display error
|
||||
# messages on the upload form due to the ajax upload already occurring.
|
||||
# When we re-engineer the upload process ( currently under way ), we
|
||||
# will be able to check the form values before the ajax upload occurs
|
||||
@@ -857,7 +860,6 @@ class LibraryCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
show_deleted=show_deleted,
|
||||
message=util.sanitize_text( message ),
|
||||
status='done' ) )
|
||||
|
||||
else:
|
||||
created_ldda_ids = ''
|
||||
message = "Upload failed"
|
||||
@@ -873,7 +875,7 @@ class LibraryCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
show_deleted=show_deleted,
|
||||
message=util.sanitize_text( message ),
|
||||
status=status ) )
|
||||
# Note: if the upload form was submitted due to refresh_on_demand for a form field, we cannot re-populate
|
||||
# Note: if the upload form was submitted due to refresh_on_change for a form field, we cannot re-populate
|
||||
# the field for the selected file ( files_0|file_data ) if the user selected one. This is because the value
|
||||
# attribute of the html input file type field is typically ignored by browsers as a security precaution.
|
||||
|
||||
@@ -881,53 +883,33 @@ class LibraryCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
info_association, inherited = folder.get_info_association( inherited=True )
|
||||
if info_association and info_association.inheritable:
|
||||
widgets = folder.get_template_widgets( trans, get_contents=True )
|
||||
# Handle form submission via refresh_on_change by keeping the contents of widget fields
|
||||
populated_widgets = []
|
||||
for index, widget_dict in enumerate( widgets ):
|
||||
widget = widget_dict[ 'widget' ]
|
||||
if isinstance( widget, AddressField ):
|
||||
value = util.restore_text( params.get( 'field_%i' % index, '' ) )
|
||||
if value:
|
||||
if value == 'new':
|
||||
# Adding a new address
|
||||
widget.value = value
|
||||
widget_dict[ 'widget' ] = widget
|
||||
elif value == 'none':
|
||||
widget.value = ''
|
||||
widget_dict[ 'widget' ] = widget
|
||||
else:
|
||||
# An existing address object was selected
|
||||
address_obj = trans.sa_session.query( trans.app.model.UserAddress ).get( int( value ) )
|
||||
widget_dict[ 'widget' ] = address_obj
|
||||
populated_widgets.append( widget_dict )
|
||||
widgets = populated_widgets
|
||||
# Retain contents of widget fields when form was submitted via refresh_on_change.
|
||||
widgets = self.populate_widgets_from_kwd( trans, widgets, **kwd )
|
||||
else:
|
||||
widgets = []
|
||||
upload_option = params.get( 'upload_option', 'upload_file' )
|
||||
# No dataset(s) specified, so display the upload form. Send list of data formats to the form
|
||||
# so the "extension" select list can be populated dynamically
|
||||
# Send list of data formats to the upload form so the "extension" select list can be populated dynamically
|
||||
file_formats = trans.app.datatypes_registry.upload_file_formats
|
||||
# Send list of genome builds to the form so the "dbkey" select list can be populated dynamically
|
||||
def get_dbkey_options( last_used_build ):
|
||||
for dbkey, build_name in util.dbnames:
|
||||
yield build_name, dbkey, ( dbkey==last_used_build )
|
||||
dbkeys = get_dbkey_options( last_used_build )
|
||||
# Send list of legitimate roles to the form so the dataset can be associated with 1 or more of them.
|
||||
# If the library is public, all active roles are legitimate. If the library is restricted by the
|
||||
# LIBRARY_ACCESS permission, only those roles associated with that permission are legitimate.
|
||||
roles = trans.app.security_agent.get_legitimate_roles( trans, library, cntrller )
|
||||
# Send the current history to the form to enable importing datasets from history to library
|
||||
history = trans.get_history()
|
||||
trans.sa_session.refresh( history )
|
||||
# If we're using nginx upload, override the form action
|
||||
action = web.url_for( controller='library_common', action='upload_library_dataset' )
|
||||
if upload_option == 'upload_file' and trans.app.config.nginx_upload_path:
|
||||
# If we're using nginx upload, override the form action -
|
||||
# url_for is intentionally not used on the base URL here -
|
||||
# nginx_upload_path is expected to include the proxy prefix if the
|
||||
# administrator intends for it to be part of the URL.
|
||||
action = trans.app.config.nginx_upload_path + '?nginx_redir=' + web.url_for( controller='library_common', action='upload_library_dataset' )
|
||||
else:
|
||||
action = web.url_for( controller='library_common', action='upload_library_dataset' )
|
||||
upload_option_select_list = self._build_upload_option_select_list( trans, upload_option )
|
||||
roles_select_list = self._build_roles_select_list( trans, cntrller, library, roles )
|
||||
return trans.fill_template( '/library/common/upload.mako',
|
||||
cntrller=cntrller,
|
||||
upload_option_select_list=upload_option_select_list,
|
||||
upload_option=upload_option,
|
||||
action=action,
|
||||
library_id=library_id,
|
||||
@@ -936,10 +918,13 @@ class LibraryCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
file_formats=file_formats,
|
||||
dbkeys=dbkeys,
|
||||
last_used_build=last_used_build,
|
||||
roles=roles,
|
||||
roles_select_list=roles_select_list,
|
||||
history=history,
|
||||
widgets=widgets,
|
||||
space_to_tab=space_to_tab,
|
||||
link_data_only=link_data_only,
|
||||
show_deleted=show_deleted,
|
||||
ldda_message=ldda_message,
|
||||
message=message,
|
||||
status=status )
|
||||
def upload_dataset( self, trans, cntrller, library_id, folder_id, replace_dataset=None, **kwd ):
|
||||
@@ -1137,13 +1122,26 @@ class LibraryCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
@web.expose
|
||||
def add_history_datasets_to_library( self, trans, cntrller, library_id, folder_id, hda_ids='', **kwd ):
|
||||
params = util.Params( kwd )
|
||||
show_deleted = util.string_as_bool( params.get( 'show_deleted', False ) )
|
||||
use_panels = util.string_as_bool( params.get( 'use_panels', False ) )
|
||||
message = util.restore_text( params.get( 'message', '' ) )
|
||||
status = params.get( 'status', 'done' )
|
||||
ldda_message = util.restore_text( params.get( 'ldda_message', '' ) )
|
||||
show_deleted = util.string_as_bool( params.get( 'show_deleted', False ) )
|
||||
use_panels = util.string_as_bool( params.get( 'use_panels', False ) )
|
||||
replace_id = params.get( 'replace_id', None )
|
||||
replace_dataset = None
|
||||
is_admin = trans.user_is_admin() and cntrller == 'library_admin'
|
||||
upload_option = params.get( 'upload_option', 'import_from_history' )
|
||||
if params.get( 'files_0|space_to_tab', False ):
|
||||
space_to_tab = params.get( 'files_0|space_to_tab', '' )
|
||||
else:
|
||||
space_to_tab = params.get( 'space_to_tab', '' )
|
||||
link_data_only = params.get( 'link_data_only', '' )
|
||||
dbkey = params.get( 'dbkey', '?' )
|
||||
if isinstance( dbkey, list ):
|
||||
last_used_build = dbkey[0]
|
||||
else:
|
||||
last_used_build = dbkey
|
||||
roles = params.get( 'roles', '' )
|
||||
is_admin = trans.user_is_admin() and cntrller in ( 'library_admin', 'api' )
|
||||
current_user_roles = trans.get_current_user_roles()
|
||||
if replace_id not in [ None, 'None' ]:
|
||||
try:
|
||||
@@ -1156,10 +1154,7 @@ class LibraryCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
folder = replace_dataset.folder
|
||||
last_used_build = replace_dataset.library_dataset_dataset_association.dbkey
|
||||
else:
|
||||
try:
|
||||
folder = trans.sa_session.query( trans.app.model.LibraryFolder ).get( trans.security.decode_id( folder_id ) )
|
||||
except:
|
||||
folder = None
|
||||
folder = trans.sa_session.query( trans.app.model.LibraryFolder ).get( trans.security.decode_id( folder_id ) )
|
||||
self._check_access( trans, cntrller, is_admin, folder, current_user_roles, use_panels, library_id, show_deleted )
|
||||
self._check_add( trans, cntrller, is_admin, folder, current_user_roles, use_panels, library_id, show_deleted )
|
||||
library = folder.parent_library
|
||||
@@ -1187,7 +1182,16 @@ class LibraryCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
except:
|
||||
hda = None
|
||||
self._check_access( trans, cntrller, is_admin, hda, current_user_roles, use_panels, library_id, show_deleted )
|
||||
ldda = hda.to_library_dataset_dataset_association( target_folder=folder, replace_dataset=replace_dataset )
|
||||
if roles:
|
||||
role_ids = roles.split( ',' )
|
||||
role_obj_list = [ trans.sa_session.query( trans.model.Role ).get( role_id ) for role_id in role_ids ]
|
||||
else:
|
||||
role_obj_list = []
|
||||
ldda = hda.to_library_dataset_dataset_association( trans,
|
||||
target_folder=folder,
|
||||
replace_dataset=replace_dataset,
|
||||
roles=role_obj_list,
|
||||
ldda_message=ldda_message )
|
||||
created_ldda_ids = '%s,%s' % ( created_ldda_ids, str( ldda.id ) )
|
||||
dataset_names.append( ldda.name )
|
||||
if not replace_dataset:
|
||||
@@ -1235,31 +1239,72 @@ class LibraryCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
message = 'Select at least one dataset from the list of active datasets in your current history'
|
||||
status = 'error'
|
||||
upload_option = params.get( 'upload_option', 'import_from_history' )
|
||||
# Send list of data formats to the form so the "extension" select list can be populated dynamically
|
||||
widgets = self._get_populated_widgets( folder )
|
||||
# Send list of data formats to the upload form so the "extension" select list can be populated dynamically
|
||||
file_formats = trans.app.datatypes_registry.upload_file_formats
|
||||
# Send list of genome builds to the form so the "dbkey" select list can be populated dynamically
|
||||
def get_dbkey_options( last_used_build ):
|
||||
for dbkey, build_name in util.dbnames:
|
||||
yield build_name, dbkey, ( dbkey==last_used_build )
|
||||
dbkeys = get_dbkey_options( last_used_build )
|
||||
# Send list of legitimate roles to the form so the dataset can be associated with 1 or more of them.
|
||||
roles = trans.app.security_agent.get_legitimate_roles( trans, library, cntrller )
|
||||
# Send the current history to the form to enable importing datasets from history to library
|
||||
history = trans.get_history()
|
||||
trans.sa_session.refresh( history )
|
||||
action = 'add_history_datasets_to_library'
|
||||
upload_option_select_list = self._build_upload_option_select_list( trans, upload_option )
|
||||
roles_select_list = self._build_roles_select_list( trans, cntrller, library, roles )
|
||||
return trans.fill_template( "/library/common/upload.mako",
|
||||
action='add_history_datasets_to_library',
|
||||
cntrller=cntrller,
|
||||
upload_option_select_list=upload_option_select_list,
|
||||
upload_option=upload_option,
|
||||
action=action,
|
||||
library_id=library_id,
|
||||
folder_id=folder_id,
|
||||
replace_dataset=replace_dataset,
|
||||
file_formats=file_formats,
|
||||
dbkeys=dbkeys,
|
||||
last_used_build=last_used_build,
|
||||
roles=roles,
|
||||
roles_select_list=roles_select_list,
|
||||
history=history,
|
||||
widgets=[],
|
||||
widgets=widgets,
|
||||
space_to_tab=space_to_tab,
|
||||
link_data_only=link_data_only,
|
||||
show_deleted=show_deleted,
|
||||
ldda_message=ldda_message,
|
||||
message=message,
|
||||
status=status )
|
||||
def _build_roles_select_list( self, trans, cntrller, library, selected_roles ):
|
||||
# Get the list of legitimate roles to display on the upload form. If the library is public,
|
||||
# all active roles are legitimate. If the library is restricted by the LIBRARY_ACCESS permission, only
|
||||
# the set of all roles associated with users that have that permission are legitimate.
|
||||
legitimate_roles = trans.app.security_agent.get_legitimate_roles( trans, library, cntrller )
|
||||
if legitimate_roles:
|
||||
# Build the roles multi-select list using the list of legitimate roles, making sure to select any that
|
||||
# were selected before refresh_on_change, if one occurred.
|
||||
roles_select_list = SelectField( "roles", multiple="true", size="5" )
|
||||
for role in legitimate_roles:
|
||||
roles_select_list.add_option( text=role.name, value=str( role.id ), selected=str( role.id ) in selected_roles )
|
||||
return roles_select_list
|
||||
else:
|
||||
return None
|
||||
def _build_upload_option_select_list( self, trans, upload_option ):
|
||||
# Build the upload_option select list
|
||||
upload_refresh_on_change_values = [ option_value for option_value, option_label in trans.model.LibraryDataset.upload_options ]
|
||||
upload_option_select_list = SelectField( 'upload_option',
|
||||
refresh_on_change=True,
|
||||
refresh_on_change_values=upload_refresh_on_change_values )
|
||||
for option_value, option_label in trans.model.LibraryDataset.upload_options:
|
||||
upload_option_select_list.add_option( option_label, option_value, selected=option_value==upload_option )
|
||||
return upload_option_select_list
|
||||
def _get_populated_widgets( self, folder ):
|
||||
# See if we have any inherited templates.
|
||||
info_association, inherited = folder.get_info_association( inherited=True )
|
||||
if info_association and info_association.inheritable:
|
||||
widgets = folder.get_template_widgets( trans, get_contents=True )
|
||||
# Retain contents of widget fields when form was submitted via refresh_on_change.
|
||||
return self.populate_widgets_from_kwd( trans, widgets, **kwd )
|
||||
else:
|
||||
return []
|
||||
@web.expose
|
||||
def download_dataset_from_folder( self, trans, cntrller, id, library_id=None, **kwd ):
|
||||
"""Catches the dataset id and displays file contents as directed"""
|
||||
@@ -1993,6 +2038,14 @@ class LibraryCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
widget.value = ''
|
||||
else:
|
||||
widget.value = value
|
||||
elif isinstance( widget, CheckboxField ):
|
||||
# We need to check the value from kwd since util.Params would have munged the list if
|
||||
# the checkbox is checked.
|
||||
value = kwd.get( 'field_%i' % index, '' )
|
||||
if CheckboxField.is_checked( value ):
|
||||
widget.value = 'true'
|
||||
else:
|
||||
widget.value = util.restore_text( params.get( 'field_%i' % index, '' ) )
|
||||
# Save updated template field contents
|
||||
field_contents = self.clean_field_contents( widgets, **kwd )
|
||||
if field_contents:
|
||||
|
||||
@@ -15,9 +15,7 @@ from amqplib import client_0_8 as amqp
|
||||
import csv, smtplib, socket
|
||||
log = logging.getLogger( __name__ )
|
||||
|
||||
|
||||
class RequestsCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
|
||||
@web.json
|
||||
def sample_state_updates( self, trans, ids=None, states=None, cntrller=None ):
|
||||
# Avoid caching
|
||||
@@ -38,8 +36,6 @@ class RequestsCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
"html_datasets": unicode( trans.fill_template( "requests/common/sample_datasets.mako", trans=trans, sample=sample, cntrller=cntrller ), 'utf-8' )
|
||||
}
|
||||
return rval
|
||||
|
||||
|
||||
@web.expose
|
||||
@web.require_login( "create/submit sequencing requests" )
|
||||
def new(self, trans, **kwd):
|
||||
@@ -88,7 +84,6 @@ class RequestsCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
**new_kwd) )
|
||||
elif params.get('refresh', False) == 'true':
|
||||
return self.__show_request_form(trans, **kwd)
|
||||
|
||||
def __select_request_type(self, trans, rtid):
|
||||
requesttype_list = trans.user.accessible_request_types(trans)
|
||||
rt_ids = ['none']
|
||||
@@ -109,7 +104,6 @@ class RequestsCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
else:
|
||||
select_reqtype.add_option(rt.name, rt.id)
|
||||
return select_reqtype
|
||||
|
||||
def __show_request_form(self, trans, **kwd):
|
||||
params = util.Params( kwd )
|
||||
cntrller = util.restore_text( params.get( 'cntrller', 'requests' ) )
|
||||
@@ -295,8 +289,6 @@ class RequestsCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
id=trans.security.encode_id(request.id),
|
||||
message=message ,
|
||||
status='done') )
|
||||
|
||||
|
||||
@web.expose
|
||||
@web.require_login( "create/submit sequencing requests" )
|
||||
def edit(self, trans, **kwd):
|
||||
@@ -344,7 +336,6 @@ class RequestsCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
**new_kwd) )
|
||||
elif params.get('refresh', False) == 'true':
|
||||
return self.__edit_request(trans, **kwd)
|
||||
|
||||
def __edit_request(self, trans, **kwd):
|
||||
try:
|
||||
request = trans.sa_session.query( trans.app.model.Request ).get( trans.security.decode_id(kwd['id']) )
|
||||
@@ -707,7 +698,6 @@ class RequestsCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
else:
|
||||
break
|
||||
return current_samples, details, edit_mode, libraries
|
||||
|
||||
def __library_widgets(self, trans, user, sample_index, libraries, sample=None, lib_id=None, folder_id=None, **kwd):
|
||||
'''
|
||||
This method creates the data library & folder selectbox for creating &
|
||||
@@ -786,7 +776,6 @@ class RequestsCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
for i, s in enumerate(current_samples):
|
||||
copy_list.add_option(s['name'], i)
|
||||
return copy_list
|
||||
|
||||
def __sample_operation_selectbox(self, trans, request, **kwd):
|
||||
params = util.Params( kwd )
|
||||
cntrller = util.restore_text( params.get( 'cntrller', 'requests' ) )
|
||||
@@ -816,7 +805,6 @@ class RequestsCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
else:
|
||||
op_list.add_option(s, s)
|
||||
return op_list
|
||||
|
||||
def __selected_samples(self, trans, request, **kwd):
|
||||
params = util.Params( kwd )
|
||||
selected_samples = []
|
||||
@@ -824,7 +812,6 @@ class RequestsCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
if CheckboxField.is_checked(params.get('select_sample_%i' % s.id, '')):
|
||||
selected_samples.append(s.id)
|
||||
return selected_samples
|
||||
|
||||
@web.expose
|
||||
@web.require_login( "create/submit sequencing requests" )
|
||||
def request_page(self, trans, **kwd):
|
||||
@@ -873,8 +860,8 @@ class RequestsCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
lib_widget=lib_widget,
|
||||
folder_widget=folder_widget))
|
||||
else:
|
||||
src_library_id = current_samples[src_sample_index]['lib_widget'].get_selected()[1]
|
||||
src_folder_id = current_samples[src_sample_index]['folder_widget'].get_selected()[1]
|
||||
src_library_id = current_samples[src_sample_index]['lib_widget'].get_selected( return_value=True )
|
||||
src_folder_id = current_samples[src_sample_index]['folder_widget'].get_selected( return_value=True )
|
||||
for ns in range(num_sample_to_copy):
|
||||
lib_widget, folder_widget = self.__library_widgets(trans, request.user,
|
||||
len(current_samples),
|
||||
@@ -1052,7 +1039,6 @@ class RequestsCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
sample_ops=sample_ops,
|
||||
edit_mode=edit_mode, status=status, message=message,
|
||||
bulk_lib_ops=self.__library_widgets(trans, request.user, 0, libraries, None, **kwd))
|
||||
|
||||
def __import_samples(self, trans, cntrller, request, current_samples, details, libraries, **kwd):
|
||||
'''
|
||||
This method reads the samples csv file and imports all the samples
|
||||
@@ -1103,7 +1089,6 @@ class RequestsCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
id=trans.security.encode_id(request.id),
|
||||
status='error',
|
||||
message='Error in importing samples file' ))
|
||||
|
||||
def __validate_barcode(self, trans, sample, barcode):
|
||||
'''
|
||||
This method makes sure that the given barcode about to be assigned to
|
||||
@@ -1131,8 +1116,6 @@ class RequestsCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
if message:
|
||||
break
|
||||
return message
|
||||
|
||||
|
||||
@web.expose
|
||||
@web.require_login( "create/submit sequencing requests" )
|
||||
def delete_sample(self, trans, **kwd):
|
||||
@@ -1249,9 +1232,7 @@ class RequestsCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
dataset_files=sample.datasets,
|
||||
message=message, status=status, files=[],
|
||||
folder_path=folder_path )
|
||||
#
|
||||
# Find sequencing requests & samples
|
||||
#
|
||||
def __find_widgets(self, trans, **kwd):
|
||||
params = util.Params( kwd )
|
||||
request_states = SelectField('request_states', multiple=True, display="checkboxes")
|
||||
@@ -1270,7 +1251,6 @@ class RequestsCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
search_type.add_option(s, s)
|
||||
search_box = TextField('search_box', 50, kwd.get('search_box', ''))
|
||||
return request_states, search_type, search_box
|
||||
|
||||
@web.expose
|
||||
@web.require_admin
|
||||
def find( self, trans, **kwd ):
|
||||
@@ -1321,13 +1301,3 @@ class RequestsCommon( BaseController, UsesFormDefinitionWidgets ):
|
||||
cntrller=cntrller, request_states=request_states,
|
||||
samples=samples_list, search_type=search_type,
|
||||
results=results, search_box=search_box )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ class BaseField(object):
|
||||
def sample_field_types():
|
||||
return ['TextField', 'SelectField', 'CheckboxField', 'WorkflowField']
|
||||
|
||||
|
||||
class TextField(BaseField):
|
||||
"""
|
||||
A standard text input box.
|
||||
@@ -196,9 +195,10 @@ class SelectField(BaseField):
|
||||
<div><input type="checkbox" name="bar" value="3">automatic</div>
|
||||
<div><input type="checkbox" name="bar" value="4" checked>bazooty</div>
|
||||
"""
|
||||
def __init__( self, name, multiple=None, display=None, refresh_on_change = False, refresh_on_change_values = [] ):
|
||||
def __init__( self, name, multiple=None, display=None, refresh_on_change=False, refresh_on_change_values=[], size=None ):
|
||||
self.name = name
|
||||
self.multiple = multiple or False
|
||||
self.size = size
|
||||
self.options = list()
|
||||
if display == "checkboxes":
|
||||
assert multiple, "Checkbox display only supported for multiple select"
|
||||
@@ -264,7 +264,12 @@ class SelectField(BaseField):
|
||||
def get_html_default( self, prefix="", disabled=False ):
|
||||
if self.multiple:
|
||||
multiple = " multiple"
|
||||
else: multiple = ""
|
||||
else:
|
||||
multiple = ""
|
||||
if self.size:
|
||||
size = ' size="%s"' % str( self.size )
|
||||
else:
|
||||
size = ''
|
||||
rval = []
|
||||
last_selected_value = ""
|
||||
for text, value, selected in self.options:
|
||||
@@ -276,19 +281,36 @@ class SelectField(BaseField):
|
||||
rval.append( '<option value="%s"%s>%s</option>' % ( escape( str( value ), quote=True ), selected_text, text ) )
|
||||
if last_selected_value:
|
||||
last_selected_value = ' last_selected_value="%s"' % escape( str( last_selected_value ), quote=True )
|
||||
rval.insert( 0, '<select name="%s%s"%s%s%s%s>' % \
|
||||
( prefix, self.name, multiple, self.refresh_on_change_text, last_selected_value, self.get_disabled_str( disabled ), ) )
|
||||
rval.insert( 0, '<select name="%s%s"%s%s%s%s%s>' % \
|
||||
( prefix, self.name, multiple, size, self.refresh_on_change_text, last_selected_value, self.get_disabled_str( disabled ) ) )
|
||||
rval.append( '</select>' )
|
||||
return "\n".join( rval )
|
||||
def get_selected(self):
|
||||
def get_selected( self, return_label=False, return_value=False, multi=False ):
|
||||
'''
|
||||
This method returns the currently selected option's text and value
|
||||
Return the currently selected option's label, value or both as a tuple. For
|
||||
multi-select lists, a list is returned.
|
||||
'''
|
||||
for text, value, selected in self.options:
|
||||
if multi:
|
||||
selected_options = []
|
||||
for label, value, selected in self.options:
|
||||
if selected:
|
||||
return text, value
|
||||
if self.options:
|
||||
return self.options[0]
|
||||
if return_label and return_value:
|
||||
if multi:
|
||||
selected_options.append( ( label, value ) )
|
||||
else:
|
||||
return ( label, value )
|
||||
elif return_label:
|
||||
if multi:
|
||||
selected_options.append( label )
|
||||
else:
|
||||
return label
|
||||
elif return_value:
|
||||
if multi:
|
||||
selected_options.append( value )
|
||||
else:
|
||||
return value
|
||||
if multi:
|
||||
return selected_options
|
||||
return None
|
||||
|
||||
class DrillDownField( BaseField ):
|
||||
|
||||
@@ -51,7 +51,7 @@ $(document).ready(function(){
|
||||
|
||||
<%def name="render_selectbox_options( index, field_attr )">
|
||||
%if field_attr[0] == 'Type':
|
||||
%if field_attr[1].get_selected()[0] == 'SelectField':
|
||||
%if field_attr[1].get_selected( return_label=True ) == 'SelectField':
|
||||
<% options = field_attr[2] %>
|
||||
<div class="repeat-group-item">
|
||||
<div class="form-row">
|
||||
@@ -77,7 +77,7 @@ $(document).ready(function(){
|
||||
<%def name="render_field( index, field, saved )">
|
||||
%if saved:
|
||||
<h4 class="msg_head">
|
||||
<div class="form-row">${index+1}. ${field[0][1].value} (${field[2][1].get_selected()[1]})</div>
|
||||
<div class="form-row">${index+1}. ${field[0][1].value} (${field[2][1].get_selected( return_value=True )})</div>
|
||||
</h4>
|
||||
<div class="msg_body">
|
||||
%else:
|
||||
|
||||
@@ -136,17 +136,22 @@
|
||||
%endif
|
||||
</%def>
|
||||
|
||||
<%def name="render_upload_form( cntrller, upload_option, action, library_id, folder_id, replace_dataset, file_formats, dbkeys, widgets, roles, history, show_deleted )">
|
||||
<% import os, os.path %>
|
||||
<%def name="render_upload_form( cntrller, upload_option, action, library_id, folder_id, replace_dataset, file_formats, dbkeys, space_to_tab, link_data_only, widgets, roles_select_list, history, show_deleted )">
|
||||
<%
|
||||
import os, os.path
|
||||
from galaxy.web.form_builder import AddressField, CheckboxField, SelectField, TextArea, TextField, WorkflowField
|
||||
%>
|
||||
%if upload_option in [ 'upload_file', 'upload_directory', 'upload_paths' ]:
|
||||
<div class="toolForm" id="upload_library_dataset_tool_form">
|
||||
%if upload_option == 'upload_directory':
|
||||
<div class="toolFormTitle">Upload a directory of files</div>
|
||||
%elif upload_option == 'upload_paths':
|
||||
<div class="toolFormTitle">Upload files from filesystem paths</div>
|
||||
%else:
|
||||
<div class="toolFormTitle">Upload files</div>
|
||||
%endif
|
||||
<%
|
||||
if upload_option == 'upload_directory':
|
||||
tool_form_title = 'Upload a directory of files'
|
||||
elif upload_option == 'upload_paths':
|
||||
tool_form_title = 'Upload files from filesystem paths'
|
||||
else:
|
||||
tool_form_title = 'Upload files'
|
||||
%>
|
||||
<div class="toolFormTitle">${tool_form_title}</div>
|
||||
<div class="toolFormBody">
|
||||
<form name="upload_library_dataset" id="upload_library_dataset" action="${action}" enctype="multipart/form-data" method="post">
|
||||
<input type="hidden" name="tool_id" value="upload1"/>
|
||||
@@ -154,7 +159,6 @@
|
||||
<input type="hidden" name="cntrller" value="${cntrller}"/>
|
||||
<input type="hidden" name="library_id" value="${library_id}"/>
|
||||
<input type="hidden" name="folder_id" value="${folder_id}"/>
|
||||
<input type="hidden" name="upload_option" value="${upload_option}"/>
|
||||
<input type="hidden" name="show_deleted" value="${show_deleted}"/>
|
||||
%if replace_dataset not in [ None, 'None' ]:
|
||||
<input type="hidden" name="replace_id" value="${trans.security.encode_id( replace_dataset.id )}"/>
|
||||
@@ -163,6 +167,21 @@
|
||||
<div style="clear: both"></div>
|
||||
</div>
|
||||
%endif
|
||||
%if replace_dataset in [ None, 'None' ]:
|
||||
## Don't allow multiple datasets to be uploaded when replacing a dataset with a new version
|
||||
<div class="form-row">
|
||||
<label>Upload option:</label>
|
||||
<div class="form-row-input">
|
||||
${upload_option_select_list.get_html()}
|
||||
</div>
|
||||
<div class="toolParamHelp" style="clear: both;">
|
||||
Choose upload option (file, directory, filesystem paths, current history).
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
</div>
|
||||
%else:
|
||||
<input type="hidden" name="upload_option" value="upload_file"/>
|
||||
%endif
|
||||
<div class="form-row">
|
||||
<label>File Format:</label>
|
||||
<div class="form-row-input">
|
||||
@@ -268,9 +287,16 @@
|
||||
%endif
|
||||
%if upload_option in ( 'upload_directory', 'upload_paths' ):
|
||||
<div class="form-row">
|
||||
<%
|
||||
if link_data_only == 'No':
|
||||
checked = ' checked'
|
||||
else:
|
||||
checked = ''
|
||||
link_data_only_field = '<input type="checkbox" name="link_data_only" value="No"%s/>No' % checked
|
||||
%>
|
||||
<label>Copy data into Galaxy?</label>
|
||||
<div class="form-row-input">
|
||||
<input type="checkbox" name="link_data_only" value="No"/>No
|
||||
${link_data_only_field}
|
||||
</div>
|
||||
<div class="toolParamHelp" style="clear: both;">
|
||||
Normally data uploaded with this tool is copied into Galaxy's "files" directory
|
||||
@@ -290,12 +316,18 @@
|
||||
Convert spaces to tabs:
|
||||
</label>
|
||||
<div class="form-row-input">
|
||||
## The files grouping only makes sense in the upload_file context.
|
||||
%if upload_option == 'upload_file':
|
||||
<input type="checkbox" name="files_0|space_to_tab" value="Yes"/>Yes
|
||||
%else:
|
||||
<input type="checkbox" name="space_to_tab" value="Yes"/>Yes
|
||||
%endif
|
||||
<%
|
||||
if space_to_tab == 'true':
|
||||
checked = ' checked'
|
||||
else:
|
||||
checked = ''
|
||||
if upload_option == 'upload_file':
|
||||
name = 'files_0|space_to_tab'
|
||||
else:
|
||||
name = 'space_to_tab'
|
||||
space2tab = '<input type="checkbox" name="%s" value="true"%s/>Yes' % ( name, checked )
|
||||
%>
|
||||
${space2tab}
|
||||
</div>
|
||||
<div class="toolParamHelp" style="clear: both;">
|
||||
Use this option if you are entering intervals by hand.
|
||||
@@ -320,22 +352,22 @@
|
||||
<div class="form-row">
|
||||
<label>Message:</label>
|
||||
<div class="form-row-input">
|
||||
<textarea name="message" rows="3" cols="35"></textarea>
|
||||
%if ldda_message:
|
||||
<textarea name="ldda_message" rows="3" cols="35">${ldda_message}</textarea>
|
||||
%else:
|
||||
<textarea name="ldda_message" rows="3" cols="35"></textarea>
|
||||
%endif
|
||||
</div>
|
||||
<div class="toolParamHelp" style="clear: both;">
|
||||
This information will be displayed in the "Information" column for this dataset in the data library browser
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
</div>
|
||||
%if roles:
|
||||
%if roles_select_list:
|
||||
<div class="form-row">
|
||||
<label>Restrict dataset access to specific roles:</label>
|
||||
<div class="form-row-input">
|
||||
<select name="roles" multiple="true" size="5">
|
||||
%for role in roles:
|
||||
<option value="${role.id}">${role.name}</option>
|
||||
%endfor
|
||||
</select>
|
||||
${roles_select_list.get_html()}
|
||||
</div>
|
||||
<div class="toolParamHelp" style="clear: both;">
|
||||
Multi-select list - hold the appropriate key while clicking to select multiple roles. More restrictions can be applied after the upload is complete. Selecting no roles makes a dataset public.
|
||||
@@ -380,7 +412,20 @@
|
||||
%if history and history.active_datasets:
|
||||
<form name="add_history_datasets_to_library" action="${h.url_for( controller='library_common', action='add_history_datasets_to_library', cntrller=cntrller, library_id=library_id )}" enctype="multipart/form-data" method="post">
|
||||
<input type="hidden" name="folder_id" value="${folder_id}"/>
|
||||
<input type="hidden" name="upload_option" value="${upload_option}"/>
|
||||
<input type="hidden" name="show_deleted" value="${show_deleted}"/>
|
||||
<input type="hidden" name="upload_option" value="import_from_history"/>
|
||||
<input type="hidden" name="ldda_message" value="${ldda_message}"/>
|
||||
<%
|
||||
if roles_select_list:
|
||||
role_ids_selected = roles_select_list.get_selected( return_value=True, multi=True )
|
||||
if role_ids_selected:
|
||||
role_ids_selected = ','.join( role_ids_selected )
|
||||
else:
|
||||
role_ids_selected = ''
|
||||
else:
|
||||
role_ids_selected = ''
|
||||
%>
|
||||
<input type="hidden" name="roles" value="${role_ids_selected}"/>
|
||||
%if replace_dataset not in [ None, 'None' ]:
|
||||
<input type="hidden" name="replace_id" value="${trans.security.encode_id( replace_dataset.id )}"/>
|
||||
<div class="form-row">
|
||||
@@ -388,6 +433,19 @@
|
||||
<div style="clear: both"></div>
|
||||
</div>
|
||||
%endif
|
||||
## Render hidden template fields so the contents will be associated with the dataset
|
||||
%if widgets:
|
||||
%for i, field in enumerate( widgets ):
|
||||
<% widget = field[ 'widget' ] %>
|
||||
%if isinstance( field[ 'widget' ], CheckboxField ):
|
||||
%if field[ 'widget' ].checked:
|
||||
<input type="hidden" name="${widget.name}" value="true"/>
|
||||
%endif
|
||||
%else:
|
||||
<input type="hidden" name="${widget.name}" value="${widget.value}"/>
|
||||
%endif
|
||||
%endfor
|
||||
%endif
|
||||
%for hda in history.active_datasets:
|
||||
<div class="form-row">
|
||||
<input name="hda_ids" value="${trans.security.encode_id( hda.id )}" type="checkbox"/>${hda.hid}: ${hda.name}
|
||||
|
||||
@@ -69,7 +69,7 @@ $( function() {
|
||||
</div>
|
||||
</div>
|
||||
<p/>
|
||||
%if template_select_list.get_selected() != ('Select one', 'none'):
|
||||
%if template_select_list.get_selected( return_label=True, return_value=True ) != ('Select one', 'none'):
|
||||
<div class="toolForm">
|
||||
<div class="toolFormTitle">Layout of selected template</div>
|
||||
<div class="toolFormBody">
|
||||
|
||||
@@ -46,27 +46,7 @@
|
||||
${h.css( "autocomplete_tagging" )}
|
||||
</%def>
|
||||
|
||||
<b>Create new data library datasets</b>
|
||||
%if replace_dataset in [ None, 'None' ]:
|
||||
## Don't allow multiple datasets to be uploaded when replacing a dataset with a new version
|
||||
<a id="upload-librarydataset--popup" class="popup-arrow" style="display: none;">▼</a>
|
||||
<div popupmenu="upload-librarydataset--popup">
|
||||
<a class="action-button" href="${h.url_for( controller='library_common', action='upload_library_dataset', cntrller=cntrller,library_id=library_id, folder_id=folder_id, replace_id=replace_id, upload_option='upload_file', show_deleted=show_deleted )}">Upload files</a>
|
||||
%if ( trans.user_is_admin() and cntrller == 'library_admin' ):
|
||||
%if trans.app.config.library_import_dir and os.path.exists( trans.app.config.library_import_dir ):
|
||||
<a class="action-button" href="${h.url_for( controller='library_common', action='upload_library_dataset', cntrller=cntrller, library_id=library_id, folder_id=folder_id, replace_id=replace_id, upload_option='upload_directory', show_deleted=show_deleted )}">Upload directory of files</a>
|
||||
%endif
|
||||
%if trans.app.config.allow_library_path_paste:
|
||||
<a class="action-button" href="${h.url_for( controller='library_common', action='upload_library_dataset', cntrller=cntrller, library_id=library_id, folder_id=folder_id, replace_id=replace_id, upload_option='upload_paths', show_deleted=show_deleted )}">Upload files from filesystem paths</a>
|
||||
%endif
|
||||
%elif cntrller == 'library':
|
||||
%if trans.app.config.user_library_import_dir and os.path.exists( os.path.join( trans.app.config.user_library_import_dir, trans.user.email ) ):
|
||||
<a class="action-button" href="${h.url_for( controller='library_common', action='upload_library_dataset', cntrller=cntrller, library_id=library_id, folder_id=folder_id, replace_id=replace_id, upload_option='upload_directory', show_deleted=show_deleted )}">Upload directory of files</a>
|
||||
%endif
|
||||
%endif
|
||||
<a class="action-button" href="${h.url_for( controller='library_common', action='upload_library_dataset', cntrller=cntrller, library_id=library_id, folder_id=folder_id, replace_id=replace_id, upload_option='import_from_history', show_deleted=show_deleted )}">Import datasets from your current history</a>
|
||||
</div>
|
||||
%endif
|
||||
<b>Upload files to a data library</b>
|
||||
<br/><br/>
|
||||
<ul class="manage-table-actions">
|
||||
<li>
|
||||
@@ -78,4 +58,4 @@
|
||||
${render_msg( message, status )}
|
||||
%endif
|
||||
|
||||
${render_upload_form( cntrller, upload_option, action, library_id, folder_id, replace_dataset, file_formats, dbkeys, widgets, roles, history, show_deleted )}
|
||||
${render_upload_form( cntrller, upload_option, action, library_id, folder_id, replace_dataset, file_formats, dbkeys, space_to_tab, link_data_only, widgets, roles_select_list, history, show_deleted )}
|
||||
|
||||
@@ -67,7 +67,7 @@ $( function() {
|
||||
%endif
|
||||
</div>
|
||||
|
||||
%if select_request_type.get_selected() != ('Select one', 'none'):
|
||||
%if select_request_type.get_selected( return_label=True, return_value=True ) != ('Select one', 'none'):
|
||||
%for i, field in enumerate(widgets):
|
||||
<div class="form-row">
|
||||
<label>${field['label']}</label>
|
||||
|
||||
@@ -313,9 +313,9 @@ $(document).ready(function(){
|
||||
For selected sample(s):
|
||||
${sample_ops.get_html()}
|
||||
</div>
|
||||
%if 'none' not in sample_ops.get_selected() and len(selected_samples):
|
||||
%if 'none' not in sample_ops.get_selected( return_label=True, return_value=True ) and len(selected_samples):
|
||||
<div class="form-row" style="background-color:#FAFAFA;">
|
||||
%if trans.app.model.Sample.bulk_operations.CHANGE_STATE in sample_ops.get_selected():
|
||||
%if trans.app.model.Sample.bulk_operations.CHANGE_STATE in sample_ops.get_selected( return_label=True, return_value=True ):
|
||||
<%
|
||||
widgets, title = request.type.change_state_widgets(trans)
|
||||
%>
|
||||
@@ -336,12 +336,12 @@ $(document).ready(function(){
|
||||
<input type="submit" name="change_state_button" value="Save"/>
|
||||
<input type="submit" name="change_state_button" value="Cancel"/>
|
||||
</div>
|
||||
%elif trans.app.model.Sample.bulk_operations.SELECT_LIBRARY in sample_ops.get_selected():
|
||||
%elif trans.app.model.Sample.bulk_operations.SELECT_LIBRARY in sample_ops.get_selected( return_label=True, return_value=True ):
|
||||
<div class="form-row">
|
||||
<label>Select data library:</label>
|
||||
${bulk_lib_ops[0].get_html()}
|
||||
</div>
|
||||
%if not 'none' in bulk_lib_ops[0].get_selected():
|
||||
%if not 'none' in bulk_lib_ops[0].get_selected( return_label=True, return_value=True ):
|
||||
<div class="form-row">
|
||||
<label>Select folder:</label>
|
||||
${bulk_lib_ops[1].get_html()}
|
||||
|
||||
@@ -7,6 +7,13 @@ import sys
|
||||
def delete_obj( obj ):
|
||||
sa_session.delete( obj )
|
||||
sa_session.flush()
|
||||
def delete_request_type_permissions( id ):
|
||||
rtps = sa_session.query( galaxy.model.RequestTypePermissions ) \
|
||||
.filter( and_( galaxy.model.RequestTypePermissions.table.c.request_type_id==id ) ) \
|
||||
.order_by( desc( galaxy.model.RequestTypePermissions.table.c.create_time ) )
|
||||
for rtp in rtps:
|
||||
sa_session.delete( rtp )
|
||||
sa_session.flush()
|
||||
def delete_user_roles( user ):
|
||||
for ura in user.roles:
|
||||
sa_session.delete( ura )
|
||||
@@ -103,6 +110,16 @@ def get_private_role( user ):
|
||||
if role.name == user.email and role.description == 'Private Role for %s' % user.email:
|
||||
return role
|
||||
raise AssertionError( "Private role not found for user '%s'" % user.email )
|
||||
def get_request_by_name( name ):
|
||||
return sa_session.query( galaxy.model.Request ) \
|
||||
.filter( and_( galaxy.model.Request.table.c.name==name,
|
||||
galaxy.model.Request.table.c.deleted==False ) ) \
|
||||
.first()
|
||||
def get_request_type_by_name( name ):
|
||||
return sa_session.query( galaxy.model.RequestType ) \
|
||||
.filter( and_( galaxy.model.RequestType.table.c.name==name ) ) \
|
||||
.order_by( desc( galaxy.model.RequestType.table.c.create_time ) ) \
|
||||
.first()
|
||||
def get_role_by_name( name ):
|
||||
return sa_session.query( galaxy.model.Role ).filter( galaxy.model.Role.table.c.name==name ).first()
|
||||
def get_user( email ):
|
||||
@@ -126,9 +143,9 @@ def get_user_role_associations_by_role( role ):
|
||||
return sa_session.query( galaxy.model.UserRoleAssociation ) \
|
||||
.filter( galaxy.model.UserRoleAssociation.table.c.role_id == role.id ) \
|
||||
.all()
|
||||
def mark_form_deleted( form ):
|
||||
form.current.deleted = True
|
||||
sa_session.add( form )
|
||||
def mark_obj_deleted( obj ):
|
||||
obj.deleted = True
|
||||
sa_session.add( obj )
|
||||
sa_session.flush()
|
||||
def refresh( obj ):
|
||||
sa_session.refresh( obj )
|
||||
|
||||
+205
-366
@@ -231,11 +231,11 @@ class TwillTestCase( unittest.TestCase ):
|
||||
check_str = 'Deleted %d %s' % ( num_deleted, iff( num_deleted != 1, "histories", "history" ) )
|
||||
self.check_page_for_string( check_str )
|
||||
self.home()
|
||||
def delete_current_history( self, check_str='' ):
|
||||
def delete_current_history( self, strings_displayed=[] ):
|
||||
"""Deletes the current history"""
|
||||
self.home()
|
||||
self.visit_page( "history/delete_current" )
|
||||
if check_str:
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
self.home()
|
||||
def get_histories_as_data_list( self ):
|
||||
@@ -305,53 +305,47 @@ class TwillTestCase( unittest.TestCase ):
|
||||
else:
|
||||
self.new_history()
|
||||
self.home()
|
||||
def share_current_history( self, email, check_str='', check_str_after_submit='', check_str_after_submit2='',
|
||||
action='', action_check_str='', action_check_str_after_submit='' ):
|
||||
def share_current_history( self, email, strings_displayed=[], strings_displayed_after_submit=[],
|
||||
action='', action_strings_displayed=[], action_strings_displayed_after_submit=[] ):
|
||||
"""Share the current history with different users"""
|
||||
self.visit_url( "%s/history/share" % self.url )
|
||||
if check_str:
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
tc.fv( 'share', 'email', email )
|
||||
tc.submit( 'share_button' )
|
||||
if check_str_after_submit:
|
||||
self.check_page_for_string( check_str_after_submit )
|
||||
if check_str_after_submit2:
|
||||
self.check_page_for_string( check_str_after_submit2 )
|
||||
for check_str in strings_displayed_after_submit:
|
||||
self.check_page_for_string( check_str )
|
||||
if action:
|
||||
# If we have an action, then we are sharing datasets with users that do not have access permissions on them
|
||||
if action_check_str:
|
||||
self.check_page_for_string( action_check_str )
|
||||
for check_str in action_strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
tc.fv( 'share_restricted', 'action', action )
|
||||
tc.submit( "share_restricted_button" )
|
||||
if action_check_str_after_submit:
|
||||
self.check_page_for_string( action_check_str_after_submit )
|
||||
for check_str in action_strings_displayed_after_submit:
|
||||
self.check_page_for_string( check_str )
|
||||
self.home()
|
||||
def share_histories_with_users( self, ids, emails, check_str1='', check_str2='',
|
||||
check_str_after_submit='', action=None, action_check_str=None ):
|
||||
def share_histories_with_users( self, ids, emails, strings_displayed=[], strings_displayed_after_submit=[],
|
||||
action=None, action_strings_displayed=[] ):
|
||||
"""Share one or more histories with one or more different users"""
|
||||
self.visit_url( "%s/history/list?id=%s&operation=Share" % ( self.url, ids ) )
|
||||
if check_str1:
|
||||
self.check_page_for_string( check_str1 )
|
||||
if check_str2:
|
||||
self.check_page_for_string( check_str2 )
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
tc.fv( 'share', 'email', emails )
|
||||
tc.submit( 'share_button' )
|
||||
if check_str_after_submit:
|
||||
self.check_page_for_string( check_str_after_submit )
|
||||
for check_str in strings_displayed_after_submit:
|
||||
self.check_page_for_string( check_str )
|
||||
if action:
|
||||
# If we have an action, then we are sharing datasets with users that do not have access permissions on them
|
||||
tc.fv( 'share_restricted', 'action', action )
|
||||
tc.submit( "share_restricted_button" )
|
||||
if action_check_str:
|
||||
self.check_page_for_string( action_check_str )
|
||||
for check_str in action_strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
self.home()
|
||||
def unshare_history( self, history_id, user_id, check_str1='', check_str2='', check_str_after_submit='' ):
|
||||
def unshare_history( self, history_id, user_id, strings_displayed=[] ):
|
||||
"""Unshare a history that has been shared with another user"""
|
||||
self.visit_url( "%s/history/list?id=%s&operation=share+or+publish" % ( self.url, history_id ) )
|
||||
if check_str1:
|
||||
self.check_page_for_string( check_str1 )
|
||||
if check_str2:
|
||||
self.check_page_for_string( check_str2 )
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
self.visit_url( "%s/history/sharing?unshare_user=%s&id=%s" % ( self.url, user_id, history_id ) )
|
||||
self.home()
|
||||
def switch_history( self, id='', name='' ):
|
||||
@@ -360,7 +354,7 @@ class TwillTestCase( unittest.TestCase ):
|
||||
if name:
|
||||
self.check_history_for_string( name )
|
||||
self.home()
|
||||
def view_stored_active_histories( self, check_str='' ):
|
||||
def view_stored_active_histories( self, strings_displayed=[] ):
|
||||
self.home()
|
||||
self.visit_page( "history/list" )
|
||||
self.check_page_for_string( 'Saved Histories' )
|
||||
@@ -368,65 +362,63 @@ class TwillTestCase( unittest.TestCase ):
|
||||
self.check_page_for_string( 'operation=Rename' )
|
||||
self.check_page_for_string( 'operation=Switch' )
|
||||
self.check_page_for_string( 'operation=Delete' )
|
||||
if check_str:
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
self.home()
|
||||
def view_stored_deleted_histories( self, check_str='' ):
|
||||
def view_stored_deleted_histories( self, strings_displayed=[] ):
|
||||
self.home()
|
||||
self.visit_page( "history/list?f-deleted=True" )
|
||||
self.check_page_for_string( 'Saved Histories' )
|
||||
self.check_page_for_string( '<input type="checkbox" name="id" value=' )
|
||||
self.check_page_for_string( 'operation=Undelete' )
|
||||
if check_str:
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
self.home()
|
||||
def view_shared_histories( self, check_str='', check_str2='' ):
|
||||
def view_shared_histories( self, strings_displayed=[] ):
|
||||
self.home()
|
||||
self.visit_page( "history/list_shared" )
|
||||
if check_str:
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
if check_str2:
|
||||
self.check_page_for_string( check_str2 )
|
||||
self.home()
|
||||
def clone_history( self, history_id, clone_choice, check_str1='', check_str_after_submit='' ):
|
||||
def clone_history( self, history_id, clone_choice, strings_displayed=[], strings_displayed_after_submit=[] ):
|
||||
self.home()
|
||||
self.visit_page( "history/clone?id=%s" % history_id )
|
||||
if check_str1:
|
||||
self.check_page_for_string( check_str1 )
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
tc.fv( '1', 'clone_choice', clone_choice )
|
||||
tc.submit( 'clone_choice_button' )
|
||||
if check_str_after_submit:
|
||||
self.check_page_for_string( check_str_after_submit )
|
||||
for check_str in strings_displayed_after_submit:
|
||||
self.check_page_for_string( check_str )
|
||||
self.home()
|
||||
def make_accessible_via_link( self, history_id, check_str='', check_str_after_submit='' ):
|
||||
def make_accessible_via_link( self, history_id, strings_displayed=[], strings_displayed_after_submit=[] ):
|
||||
self.home()
|
||||
self.visit_page( "history/list?operation=share+or+publish&id=%s" % history_id )
|
||||
if check_str:
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
# twill barfs on this form, possibly because it contains no fields, but not sure.
|
||||
# In any case, we have to mimic the form submission
|
||||
self.home()
|
||||
self.visit_page( 'history/sharing?id=%s&make_accessible_via_link=True' % history_id )
|
||||
if check_str_after_submit:
|
||||
self.check_page_for_string( check_str_after_submit )
|
||||
for check_str in strings_displayed_after_submit:
|
||||
self.check_page_for_string( check_str )
|
||||
self.home()
|
||||
def disable_access_via_link( self, history_id, check_str='', check_str_after_submit='' ):
|
||||
def disable_access_via_link( self, history_id, strings_displayed=[], strings_displayed_after_submit=[] ):
|
||||
self.home()
|
||||
self.visit_page( "history/list?operation=share+or+publish&id=%s" % history_id )
|
||||
if check_str:
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
# twill barfs on this form, possibly because it contains no fields, but not sure.
|
||||
# In any case, we have to mimic the form submission
|
||||
self.home()
|
||||
self.visit_page( 'history/sharing?id=%s&disable_link_access=True' % history_id )
|
||||
if check_str_after_submit:
|
||||
self.check_page_for_string( check_str_after_submit )
|
||||
for check_str in strings_displayed_after_submit:
|
||||
self.check_page_for_string( check_str )
|
||||
self.home()
|
||||
def import_history_via_url( self, history_id, email, check_str_after_submit='' ):
|
||||
def import_history_via_url( self, history_id, email, strings_displayed_after_submit=[] ):
|
||||
self.home()
|
||||
self.visit_page( "history/imp?&id=%s" % history_id )
|
||||
if check_str_after_submit:
|
||||
self.check_page_for_string( check_str_after_submit )
|
||||
for check_str in strings_displayed_after_submit:
|
||||
self.check_page_for_string( check_str )
|
||||
self.home()
|
||||
|
||||
# Functions associated with datasets (history items) and meta data
|
||||
@@ -453,39 +445,38 @@ class TwillTestCase( unittest.TestCase ):
|
||||
self.visit_page( "edit?hid=%s" % hid )
|
||||
for subpatt in patt.split():
|
||||
tc.find(subpatt)
|
||||
def delete_history_item( self, hda_id, check_str='' ):
|
||||
def delete_history_item( self, hda_id, strings_displayed=[] ):
|
||||
"""Deletes an item from a history"""
|
||||
try:
|
||||
hda_id = int( hda_id )
|
||||
except:
|
||||
raise AssertionError, "Invalid hda_id '%s' - must be int" % hda_id
|
||||
self.visit_url( "%s/root/delete?show_deleted_on_refresh=False&id=%s" % ( self.url, hda_id ) )
|
||||
if check_str:
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
def undelete_history_item( self, hda_id, check_str='' ):
|
||||
def undelete_history_item( self, hda_id, strings_displayed=[] ):
|
||||
"""Un-deletes a deleted item in a history"""
|
||||
try:
|
||||
hda_id = int( hda_id )
|
||||
except:
|
||||
raise AssertionError, "Invalid hda_id '%s' - must be int" % hda_id
|
||||
self.visit_url( "%s/dataset/undelete?id=%s" % ( self.url, hda_id ) )
|
||||
if check_str:
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
def display_history_item( self, hda_id, check_str='' ):
|
||||
def display_history_item( self, hda_id, strings_displayed=[] ):
|
||||
"""Displays a history item - simulates eye icon click"""
|
||||
self.visit_url( '%s/datasets/%s/display/' % ( self.url, self.security.encode_id( hda_id ) ) )
|
||||
if check_str:
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
self.home()
|
||||
def view_history( self, history_id, check_str='' ):
|
||||
def view_history( self, history_id, strings_displayed=[] ):
|
||||
"""Displays a history for viewing"""
|
||||
self.visit_url( '%s/history/view?id=%s' % ( self.url, self.security.encode_id( history_id ) ) )
|
||||
if check_str:
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
self.home()
|
||||
def edit_hda_attribute_info( self, hda_id, new_name='', new_info='', new_dbkey='', new_startcol='',
|
||||
check_str1='', check_str2='', check_str3='', check_str4='',
|
||||
not_displayed1='', not_displayed2='', not_displayed3='' ):
|
||||
strings_displayed=[], strings_not_displayed=[] ):
|
||||
"""Edit history_dataset_association attribute information"""
|
||||
self.home()
|
||||
self.visit_url( "%s/root/edit?id=%s" % ( self.url, hda_id ) )
|
||||
@@ -506,43 +497,19 @@ class TwillTestCase( unittest.TestCase ):
|
||||
if submit_required:
|
||||
tc.submit( 'save' )
|
||||
self.check_page_for_string( 'Attributes updated' )
|
||||
if check_str1:
|
||||
self.check_page_for_string( check_str1 )
|
||||
if check_str2:
|
||||
self.check_page_for_string( check_str2 )
|
||||
if check_str3:
|
||||
self.check_page_for_string( check_str3 )
|
||||
if check_str4:
|
||||
self.check_page_for_string( check_str4 )
|
||||
if not_displayed1:
|
||||
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( not_displayed1 )
|
||||
raise AssertionError, "String (%s) incorrectly displayed on Edit Attributes page." % not_displayed
|
||||
except:
|
||||
pass
|
||||
if not_displayed2:
|
||||
try:
|
||||
self.check_page_for_string( not_displayed2 )
|
||||
raise AssertionError, "String (%s) incorrectly displayed on Edit Attributes page." % not_displayed
|
||||
except:
|
||||
pass
|
||||
if not_displayed3:
|
||||
try:
|
||||
self.check_page_for_string( not_displayed3 )
|
||||
raise AssertionError, "String (%s) incorrectly displayed on Edit Attributes page." % not_displayed
|
||||
self.check_page_for_string( check_str )
|
||||
raise AssertionError, "String (%s) incorrectly displayed on Edit Attributes page." % check_str
|
||||
except:
|
||||
pass
|
||||
self.home()
|
||||
def check_hda_attribute_info( self, hda_id, check_str1='', check_str2='', check_str3='', check_str4='' ):
|
||||
def check_hda_attribute_info( self, hda_id, strings_displayed=[] ):
|
||||
"""Edit history_dataset_association attribute information"""
|
||||
if check_str1:
|
||||
self.check_page_for_string( check_str1 )
|
||||
if check_str2:
|
||||
self.check_page_for_string( check_str2 )
|
||||
if check_str3:
|
||||
self.check_page_for_string( check_str3 )
|
||||
if check_str4:
|
||||
self.check_page_for_string( check_str4 )
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
def auto_detect_metadata( self, hda_id ):
|
||||
"""Auto-detect history_dataset_association metadata"""
|
||||
self.home()
|
||||
@@ -673,16 +640,16 @@ class TwillTestCase( unittest.TestCase ):
|
||||
self.files_re_match( local_name, temp_name, attributes=attributes )
|
||||
elif compare == 're_match_multiline':
|
||||
self.files_re_match_multiline( local_name, temp_name, attributes=attributes )
|
||||
elif compare == 'sim_size':
|
||||
delta = attributes.get('delta','100')
|
||||
s1 = len(data)
|
||||
s2 = os.path.getsize(local_name)
|
||||
if abs(s1-s2) > int(delta):
|
||||
raise Exception, 'Files %s=%db but %s=%db - compare (delta=%s) failed' % (temp_name,s1,local_name,s2,delta)
|
||||
else:
|
||||
raise Exception, 'Unimplemented Compare type: %s' % compare
|
||||
if extra_files:
|
||||
self.verify_extra_files_content( extra_files, elem.get( 'id' ) )
|
||||
elif compare == 'sim_size':
|
||||
delta = attributes.get('delta','100')
|
||||
s1 = len(data)
|
||||
s2 = os.path.getsize(local_name)
|
||||
if abs(s1-s2) > int(delta):
|
||||
raise Exception, 'Files %s=%db but %s=%db - compare (delta=%s) failed' % (temp_name,s1,local_name,s2,delta)
|
||||
else:
|
||||
raise Exception, 'Unimplemented Compare type: %s' % compare
|
||||
if extra_files:
|
||||
self.verify_extra_files_content( extra_files, elem.get( 'id' ) )
|
||||
except AssertionError, err:
|
||||
errmsg = 'History item %s different than expected, difference (using %s):\n' % ( hid, compare )
|
||||
errmsg += str( err )
|
||||
@@ -801,9 +768,7 @@ class TwillTestCase( unittest.TestCase ):
|
||||
pass
|
||||
return previously_created, username_taken, invalid_username
|
||||
def create_user_with_info( self, email, password, username, user_info_forms, user_info_form_id, user_info_values ):
|
||||
'''
|
||||
This method registers a new user and also provides use info
|
||||
'''
|
||||
# This method creates a new user with associated info
|
||||
if user_info_forms == 'multiple':
|
||||
self.visit_url( "%s/user/create?user_info_select=%i&admin_view=False&use_panels=False" % ( self.url, user_info_form_id ) )
|
||||
else:
|
||||
@@ -819,7 +784,7 @@ class TwillTestCase( unittest.TestCase ):
|
||||
tc.fv( "1", "field_%i" % index, info_value )
|
||||
tc.submit( "create_user_button" )
|
||||
def create_user_with_info_as_admin( self, email, password, username, user_info_forms, user_info_form_id, user_info_values ):
|
||||
# This method creates a new user with associated info
|
||||
# This method creates a new user with associated info from the admin view
|
||||
self.home()
|
||||
if user_info_forms == 'multiple':
|
||||
self.visit_page( "admin/users?operation=create?user_info_select=%i&admin_view=False" % user_info_form_id )
|
||||
@@ -836,15 +801,15 @@ class TwillTestCase( unittest.TestCase ):
|
||||
tc.fv( "2", "field_%i" % index, info_value )
|
||||
tc.submit( "create_user_button" )
|
||||
self.check_page_for_string( "Created new user account (%s)" % email )
|
||||
def edit_login_info( self, new_email, new_username, check_str1='' ):
|
||||
def edit_login_info( self, new_email, new_username, strings_displayed=[] ):
|
||||
self.home()
|
||||
self.visit_url( "%s/user/show_info" % self.url )
|
||||
self.check_page_for_string( "Manage User Information" )
|
||||
tc.fv( "login_info", "email", new_email )
|
||||
tc.fv( "login_info", "username", new_username )
|
||||
tc.submit( "login_info_button" )
|
||||
if check_str1:
|
||||
self.check_page_for_string( check_str1 )
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
def change_password( self, password, new_password ):
|
||||
self.home()
|
||||
self.visit_page( "user/show_info" )
|
||||
@@ -1211,7 +1176,7 @@ class TwillTestCase( unittest.TestCase ):
|
||||
self.check_page_for_string( check_str )
|
||||
self.home()
|
||||
def manage_roles_and_groups_for_user( self, user_id, in_role_ids=[], out_role_ids=[],
|
||||
in_group_ids=[], out_group_ids=[], check_str='' ):
|
||||
in_group_ids=[], out_group_ids=[], strings_displayed=[] ):
|
||||
self.home()
|
||||
url = "%s/admin/manage_roles_and_groups_for_user?id=%s" % ( self.url, user_id )
|
||||
if in_role_ids:
|
||||
@@ -1225,15 +1190,15 @@ class TwillTestCase( unittest.TestCase ):
|
||||
if in_role_ids or out_role_ids or in_group_ids or out_group_ids:
|
||||
url += "&user_roles_groups_edit_button=Save"
|
||||
self.visit_url( url )
|
||||
if check_str:
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
self.home()
|
||||
|
||||
# Tests associated with roles
|
||||
def browse_roles( self, check_str1='' ):
|
||||
def browse_roles( self, strings_displayed=[] ):
|
||||
self.visit_url( '%s/admin/roles' % self.url )
|
||||
if check_str1:
|
||||
self.check_page_for_string( check_str1 )
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
def create_role( self,
|
||||
name='Role One',
|
||||
description="This is Role One",
|
||||
@@ -1298,7 +1263,6 @@ class TwillTestCase( unittest.TestCase ):
|
||||
"""Purge an existing role"""
|
||||
self.home()
|
||||
self.visit_url( "%s/admin/roles?operation=purge&id=%s" % ( self.url, role_id ) )
|
||||
check_str = "The following have been purged from the database for role '%s': " % role_name
|
||||
check_str = "Purged 1 roles: %s" % role_name
|
||||
self.check_page_for_string( check_str )
|
||||
self.home()
|
||||
@@ -1330,10 +1294,10 @@ class TwillTestCase( unittest.TestCase ):
|
||||
self.visit_url( "%s/admin/groups" % self.url )
|
||||
self.check_page_for_string( name )
|
||||
self.home()
|
||||
def browse_groups( self, check_str1='' ):
|
||||
def browse_groups( self, strings_displayed=[] ):
|
||||
self.visit_url( '%s/admin/groups' % self.url )
|
||||
if check_str1:
|
||||
self.check_page_for_string( check_str1 )
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
def rename_group( self, group_id, name='Group One Renamed' ):
|
||||
"""Rename a group"""
|
||||
self.home()
|
||||
@@ -1699,43 +1663,34 @@ class TwillTestCase( unittest.TestCase ):
|
||||
else:
|
||||
self.check_page_for_string = 'will now be inherited to contained folders and datasets'
|
||||
self.home()
|
||||
def browse_libraries_admin( self, deleted=False, check_str1='', check_str2='', not_displayed1='' ):
|
||||
def browse_libraries_admin( self, deleted=False, strings_displayed=[], strings_not_displayed=[] ):
|
||||
self.visit_url( '%s/library_admin/browse_libraries?sort=name&f-description=All&f-name=All&f-deleted=%s' % ( self.url, str( deleted ) ) )
|
||||
if check_str1:
|
||||
self.check_page_for_string( check_str1 )
|
||||
if check_str2:
|
||||
self.check_page_for_string( check_str2 )
|
||||
if not_displayed1:
|
||||
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( not_displayed1 )
|
||||
raise AssertionError, "String (%s) incorrectly displayed when browing library." % not_displayed1
|
||||
self.check_page_for_string( check_str )
|
||||
raise AssertionError, "String (%s) incorrectly displayed when browing library." % check_str
|
||||
except:
|
||||
pass
|
||||
def browse_libraries_regular_user( self, check_str1='', check_str2='', not_displayed1='' ):
|
||||
def browse_libraries_regular_user( self, strings_displayed=[], strings_not_displayed=[] ):
|
||||
self.visit_url( '%s/library/browse_libraries' % self.url )
|
||||
if check_str1:
|
||||
self.check_page_for_string( check_str1 )
|
||||
if check_str2:
|
||||
self.check_page_for_string( check_str2 )
|
||||
if not_displayed1:
|
||||
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( not_displayed1 )
|
||||
raise AssertionError, "String (%s) incorrectly displayed when browing library." % not_displayed1
|
||||
self.check_page_for_string( check_str )
|
||||
raise AssertionError, "String (%s) incorrectly displayed when browing library." % check_str
|
||||
except:
|
||||
pass
|
||||
def browse_library( self, cntrller, id, show_deleted=False,
|
||||
check_str1='', check_str2='', check_str3='', not_displayed='', not_displayed2='' ):
|
||||
def browse_library( self, cntrller, 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, id, str( show_deleted ) ) )
|
||||
if check_str1:
|
||||
self.check_page_for_string( check_str1 )
|
||||
if check_str2:
|
||||
self.check_page_for_string( check_str2 )
|
||||
if check_str3:
|
||||
self.check_page_for_string( check_str3 )
|
||||
if not_displayed:
|
||||
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( not_displayed )
|
||||
raise AssertionError, "String (%s) incorrectly displayed when browing library." % not_displayed
|
||||
self.check_page_for_string( check_str )
|
||||
raise AssertionError, "String (%s) incorrectly displayed when browing library." % check_str
|
||||
except:
|
||||
pass
|
||||
def create_library( self, name='Library One', description='This is Library One', synopsis='Synopsis for Library One' ):
|
||||
@@ -1767,34 +1722,24 @@ class TwillTestCase( unittest.TestCase ):
|
||||
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 library_info( self, cntrller, library_id, library_name, new_name='', new_description='', new_synopsis='',
|
||||
ele_1_field_name='', ele_1_contents='', ele_2_field_name='', ele_2_contents='', check_str1='' ):
|
||||
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 ) )
|
||||
if check_str1:
|
||||
self.check_page_for_string( check_str1 )
|
||||
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 there is a template, then there are 2 forms on this page and the template is the 2nd form
|
||||
if ele_1_field_name and ele_1_contents and ele_2_field_name and ele_2_contents:
|
||||
tc.fv( '2', ele_1_field_name, ele_1_contents )
|
||||
tc.fv( '2', ele_2_field_name, ele_2_contents )
|
||||
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' )
|
||||
elif ele_1_field_name and ele_1_contents:
|
||||
tc.fv( '2', ele_1_field_name, ele_1_contents )
|
||||
tc.submit( 'edit_info_button' )
|
||||
self.home()
|
||||
def set_library_info_field_template_field( self, cntrller, library_id, field_value ):
|
||||
"""Set the value of a single field in a template containing a field of type: CheckboxField, SelectField"""
|
||||
self.visit_url( "%s/library_common/library_info?cntrller=%s&id=%s" % ( self.url, cntrller, library_id ) )
|
||||
# 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_0", field_value )
|
||||
tc.submit( 'edit_info_button' )
|
||||
self.home()
|
||||
def library_permissions( self, library_id, library_name, role_ids_str, permissions_in, permissions_out, cntrller='library_admin' ):
|
||||
# role_ids_str must be a comma-separated string of role ids
|
||||
@@ -1839,112 +1784,103 @@ class TwillTestCase( unittest.TestCase ):
|
||||
self.check_page_for_string( check_str )
|
||||
self.home()
|
||||
def folder_info( self, cntrller, folder_id, library_id, name='', new_name='', description='',
|
||||
field_name='', contents='', check_str1='', check_str2='', not_displayed='' ):
|
||||
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 ) )
|
||||
# Twill cannot handle the following call for some reason - it's buggy
|
||||
# self.check_page_for_string( "Edit folder name and description" )
|
||||
if name and new_name and description:
|
||||
tc.fv( '1', "name", new_name )
|
||||
tc.fv( '1', "description", description )
|
||||
tc.submit( 'rename_folder_button' )
|
||||
# Twill barfs on this, so keep it commented...
|
||||
#self.check_page_for_string( "The information has been updated." )
|
||||
if field_name and contents:
|
||||
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( "field_0", 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
|
||||
tc.fv( '2', field_name, contents )
|
||||
for field_name, field_value in template_fields:
|
||||
tc.fv( "edit_info", field_name, field_value )
|
||||
tc.submit( 'edit_info_button' )
|
||||
# Twill barfs on this, so keep it commented...
|
||||
#self.check_page_for_string( 'The information has been updated.' )
|
||||
if check_str1:
|
||||
self.check_page_for_string( check_str1 )
|
||||
if check_str2:
|
||||
self.check_page_for_string( check_str2 )
|
||||
if not_displayed:
|
||||
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( not_displayed )
|
||||
raise AssertionError, "String (%s) should not have been displayed on folder info page." % not_displayed
|
||||
self.check_page_for_string( check_str )
|
||||
raise AssertionError, "String (%s) incorrectly displayed." % check_str
|
||||
except:
|
||||
pass
|
||||
self.home()
|
||||
def save_folder_template( self, cntrller, folder_id, library_id, field_name, field_value, check_str1='', check_str2='', check_str3='' ):
|
||||
self.visit_url( "%s/library_common/folder_info?cntrller=%s&id=%s&library_id=%s" % \
|
||||
( self.url, cntrller, folder_id, library_id ) )
|
||||
if check_str1:
|
||||
self.check_page_for_string( check_str1 )
|
||||
if check_str2:
|
||||
self.check_page_for_string( check_str2 )
|
||||
if check_str3:
|
||||
self.check_page_for_string( check_str3 )
|
||||
# The 2nd form on the page contains the template, and the form is named edit_info.
|
||||
# The CheckboxField may already be checked due to inherited template contents, but twill
|
||||
# forces us to change a form value prior to submitting the form, so we'll check it.
|
||||
tc.fv( "edit_info", field_name, field_value )
|
||||
tc.submit( 'edit_info_button' )
|
||||
self.home()
|
||||
|
||||
# Library dataset stuff
|
||||
def add_library_dataset( self, cntrller, filename, library_id, folder_id, folder_name,
|
||||
file_type='auto', dbkey='hg18', roles=[], message='', root=False,
|
||||
template_field_name1='', template_field_contents1='',
|
||||
template_field_name2='', template_field_contents2='',
|
||||
template_refresh_field_name='', template_refresh_field_contents='',
|
||||
field_0_short_desc='', field_0_name='', field_0_institution='',
|
||||
field_0_address='', field_0_city='', field_0_state='', field_0_postal_code='',
|
||||
field_0_country='', show_deleted='False', upload_option='upload_file',
|
||||
check_str1='', check_str2='', check_str3='', check_str4='' ):
|
||||
"""Add a dataset to a folder"""
|
||||
filename = self.get_filename( filename )
|
||||
self.visit_url( "%s/library_common/upload_library_dataset?cntrller=%s&library_id=%s&folder_id=%s&upload_option=%s&message=%s" % \
|
||||
( self.url, cntrller, library_id, folder_id, upload_option, message.replace( ' ', '+' ) ) )
|
||||
self.check_page_for_string( 'Upload files' )
|
||||
if check_str1:
|
||||
self.check_page_for_string( check_str1 )
|
||||
if check_str2:
|
||||
self.check_page_for_string( check_str2 )
|
||||
if check_str3:
|
||||
self.check_page_for_string( check_str3 )
|
||||
if check_str4:
|
||||
self.check_page_for_string( check_str4 )
|
||||
# A template containing an AddressField may be displayed on the upload form.
|
||||
# If this is the case, we need to refresh the form with the passeed tmplate_field_name1.
|
||||
if template_refresh_field_name and template_refresh_field_contents:
|
||||
self.refresh_form( template_refresh_field_name, template_refresh_field_contents )
|
||||
tc.fv( "1", "field_0_short_desc", field_0_short_desc )
|
||||
tc.fv( "1", "field_0_name", field_0_name )
|
||||
tc.fv( "1", "field_0_institution", field_0_institution )
|
||||
tc.fv( "1", "field_0_address", field_0_address )
|
||||
tc.fv( "1", "field_0_city", field_0_city )
|
||||
tc.fv( "1", "field_0_state", field_0_state )
|
||||
tc.fv( "1", "field_0_postal_code", field_0_postal_code )
|
||||
tc.fv( "1", "field_0_country", field_0_country )
|
||||
# Add template field contents, if any...
|
||||
if template_field_name1:
|
||||
# The 2nd form on the page contains the template, and the form is named edit_info.
|
||||
tc.fv( "edit_info", template_field_name1, template_field_contents1 )
|
||||
if template_field_name2:
|
||||
# The 2nd form on the page contains the template, and the form is named edit_info.
|
||||
tc.fv( "edit_info", template_field_name2, template_field_contents2 )
|
||||
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='', dont_preserve_dirs='', roles=[], ldda_message='', hda_ids='',
|
||||
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.
|
||||
url = "%s/library_common/upload_library_dataset?cntrller=%s&library_id=%s&folder_id=%s" % \
|
||||
( self.url, cntrller, library_id, folder_id )
|
||||
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.
|
||||
url += "&replace_id=%s" % replace_id
|
||||
self.visit_url( url )
|
||||
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( "field_0", template_refresh_field_contents )
|
||||
for tup in template_fields:
|
||||
tc.fv( "1", tup[0], tup[1] )
|
||||
tc.fv( "1", "library_id", library_id )
|
||||
tc.fv( "1", "folder_id", folder_id )
|
||||
tc.fv( "1", "show_deleted", show_deleted )
|
||||
tc.formfile( "1", "files_0|file_data", filename )
|
||||
tc.fv( "1", "ldda_message", ldda_message )
|
||||
tc.fv( "1", "file_type", file_type )
|
||||
tc.fv( "1", "dbkey", dbkey )
|
||||
tc.fv( "1", "message", message.replace( '+', ' ' ) )
|
||||
if space_to_tab:
|
||||
tc.fv( "1", "space_to_tab", space_to_tab )
|
||||
if link_data_only:
|
||||
tc.fv( "1", "link_data_only", link_data_only )
|
||||
if dont_preserve_dirs:
|
||||
tc.fv( "1", "dont_preserve_dirs", dont_preserve_dirs )
|
||||
for role_id in roles:
|
||||
tc.fv( "1", "roles", role_id )
|
||||
tc.submit( "runtool_btn" )
|
||||
if root:
|
||||
check_str = "Added 1 datasets to the library '%s' (each is selected)." % folder_name
|
||||
# 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
|
||||
tc.fv( "add_history_datasets_to_library", "hda_ids", '1' )
|
||||
tc.submit( 'add_history_datasets_to_library_button' )
|
||||
else:
|
||||
check_str = "Added 1 datasets to the folder '%s' (each is selected)." % folder_name
|
||||
if filename:
|
||||
filename = self.get_filename( filename )
|
||||
tc.formfile( "1", "files_0|file_data", filename )
|
||||
elif server_dir:
|
||||
tc.fv( "1", "server_dir", server_dir )
|
||||
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 )
|
||||
self.home()
|
||||
def ldda_permissions( self, cntrller, library_id, folder_id, id, role_ids_str,
|
||||
permissions_in=[], permissions_out=[], check_str1='', ldda_name='' ):
|
||||
permissions_in=[], permissions_out=[], strings_displayed=[], ldda_name='' ):
|
||||
# role_ids_str must be a comma-separated string of role ids
|
||||
url = "%s/library_common/ldda_permissions?cntrller=%s&library_id=%s&folder_id=%s&id=%s" % \
|
||||
( self.url, cntrller, library_id, folder_id, id )
|
||||
@@ -1957,18 +1893,13 @@ class TwillTestCase( unittest.TestCase ):
|
||||
if permissions_in or permissions_out:
|
||||
url += "&update_roles_button=Save"
|
||||
self.visit_url( url )
|
||||
if check_str1:
|
||||
check_str = check_str1
|
||||
else:
|
||||
check_str = "Permissions updated for dataset '%s'." % ldda_name
|
||||
self.check_page_for_string( check_str )
|
||||
if not strings_displayed:
|
||||
strings_displayed = [ "Permissions updated for dataset '%s'." % ldda_name ]
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
self.home()
|
||||
def ldda_edit_info( self, cntrller, library_id, folder_id, ldda_id, ldda_name, new_ldda_name='',
|
||||
ele_1_field_name='', ele_1_contents='', ele_1_help='',
|
||||
ele_2_field_name='', ele_2_contents='', ele_2_help='',
|
||||
ele_3_field_name='', ele_3_contents='', ele_3_help='',
|
||||
check_str1='', check_str2='', check_str3='', check_str4='',
|
||||
not_displayed='' ):
|
||||
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 ) )
|
||||
@@ -1979,124 +1910,33 @@ class TwillTestCase( unittest.TestCase ):
|
||||
tc.submit( 'save' )
|
||||
check_str = "Attributes updated for library dataset '%s'." % new_ldda_name
|
||||
self.check_page_for_string( check_str )
|
||||
# There are 4 forms on this page and the template is the 4th form
|
||||
if ele_1_field_name and ele_1_contents:
|
||||
ele_1_contents = ele_1_contents.replace( '+', ' ' )
|
||||
tc.fv( '4', ele_1_field_name, ele_1_contents )
|
||||
if ele_2_field_name and ele_2_contents:
|
||||
ele_2_contents = ele_2_contents.replace( '+', ' ' )
|
||||
tc.fv( '4', ele_2_field_name, ele_2_contents.replace( '+', ' ' ) )
|
||||
if ele_3_field_name and ele_3_contents:
|
||||
ele_3_contents = ele_3_contents.replace( '+', ' ' )
|
||||
tc.fv( '4', ele_3_field_name, ele_3_contents )
|
||||
if ele_1_field_name:
|
||||
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( "field_0", 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' )
|
||||
self.check_page_for_string( 'This is the latest version of this library dataset' )
|
||||
self.check_page_for_string( 'The information has been updated.' )
|
||||
self.check_page_for_string( ele_1_contents )
|
||||
if ele_2_field_name:
|
||||
self.check_page_for_string( ele_2_contents )
|
||||
if ele_3_field_name:
|
||||
self.check_page_for_string( ele_3_contents )
|
||||
if ele_1_help:
|
||||
check_str = ele_1_help.replace( '+', ' ' )
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
if ele_2_help:
|
||||
check_str = ele_2_help.replace( '+', ' ' )
|
||||
self.check_page_for_string( check_str )
|
||||
if ele_2_help:
|
||||
check_str = ele_3_help.replace( '+', ' ' )
|
||||
self.check_page_for_string( check_str )
|
||||
if check_str1:
|
||||
self.check_page_for_string( check_str1 )
|
||||
if check_str2:
|
||||
self.check_page_for_string( check_str2 )
|
||||
if check_str3:
|
||||
self.check_page_for_string( check_str3 )
|
||||
if not_displayed:
|
||||
for check_str in strings_not_displayed:
|
||||
try:
|
||||
self.check_page_for_string( not_displayed )
|
||||
raise AssertionError, "String (%s) should not have been displayed on ldda Edit Attributes page." % not_displayed
|
||||
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
|
||||
self.home()
|
||||
def upload_new_dataset_version( self, cntrller, filename, library_id, folder_id, folder_name, library_dataset_id, ldda_name, file_type='auto',
|
||||
dbkey='hg18', message='', template_field_name1='', template_field_contents1='' ):
|
||||
"""Upload new version(s) of a dataset"""
|
||||
self.home()
|
||||
filename = self.get_filename( filename )
|
||||
self.visit_url( "%s/library_common/upload_library_dataset?cntrller=%s&upload_option=upload_file&library_id=%s&folder_id=%s&replace_id=%s&message=%s" % \
|
||||
( self.url, cntrller, library_id, folder_id, library_dataset_id, message ) )
|
||||
self.check_page_for_string( 'Upload files' )
|
||||
self.check_page_for_string( 'You are currently selecting a new file to replace' )
|
||||
self.check_page_for_string( ldda_name )
|
||||
tc.formfile( "1", "files_0|file_data", filename )
|
||||
tc.fv( "1", "file_type", file_type )
|
||||
tc.fv( "1", "dbkey", dbkey )
|
||||
tc.fv( "1", "message", message.replace( '+', ' ' ) )
|
||||
# Add template field contents, if any...
|
||||
if template_field_name1:
|
||||
tc.fv( "1", template_field_name1, template_field_contents1 )
|
||||
tc.submit( "runtool_btn" )
|
||||
check_str = "Added 1 dataset versions to the library dataset '%s' in the folder '%s'." % ( ldda_name, folder_name )
|
||||
self.check_page_for_string( check_str )
|
||||
self.library_wait( library_id )
|
||||
self.home()
|
||||
def add_history_datasets_to_library( self, cntrller, library_id, folder_id, folder_name, hda_id, root=False ):
|
||||
"""Copy a dataset from the current history to a library folder"""
|
||||
self.home()
|
||||
self.visit_url( "%s/library_common/add_history_datasets_to_library?cntrller=%s&library_id=%s&folder_id=%s&hda_ids=%s&add_history_datasets_to_library_button=Add+selected+datasets" % \
|
||||
( self.url, cntrller, library_id, folder_id, hda_id ) )
|
||||
if root:
|
||||
check_str = "Added 1 datasets to the library '%s' (each is selected)." % folder_name
|
||||
else:
|
||||
check_str = "Added 1 datasets to the folder '%s' (each is selected)." % folder_name
|
||||
self.check_page_for_string( check_str )
|
||||
self.home()
|
||||
def upload_directory_of_files( self, cntrller, library_id, folder_id, server_dir, file_type='auto', dbkey='hg18', roles_tuple=[],
|
||||
message='', check_str1='', check_str_after_submit='', template_field_name1='', template_field_contents1='' ):
|
||||
"""Add a directory of datasets to a folder"""
|
||||
# roles is a list of tuples: [ ( role_id, role_description ) ]
|
||||
url = "%s/library_common/upload_library_dataset?cntrller=%s&library_id=%s&folder_id=%s&upload_option=upload_directory" % \
|
||||
( self.url, cntrller, library_id, folder_id )
|
||||
self.visit_url( url )
|
||||
self.check_page_for_string( 'Upload a directory of files' )
|
||||
if check_str1:
|
||||
self.check_page_for_string( check_str1 )
|
||||
tc.fv( "1", "folder_id", folder_id )
|
||||
tc.fv( "1", "file_type", file_type )
|
||||
tc.fv( "1", "dbkey", dbkey )
|
||||
tc.fv( "1", "message", message )
|
||||
tc.fv( "1", "server_dir", server_dir )
|
||||
for role_tuple in roles_tuple:
|
||||
tc.fv( "1", "roles", role_tuple[1] ) # role_tuple[1] is the role name
|
||||
# Add template field contents, if any...
|
||||
if template_field_name1:
|
||||
tc.fv( "1", template_field_name1, template_field_contents1 )
|
||||
tc.submit( "runtool_btn" )
|
||||
if check_str_after_submit:
|
||||
try:
|
||||
self.check_page_for_string( check_str_after_submit )
|
||||
except:
|
||||
self.library_wait( library_id )
|
||||
try:
|
||||
self.check_page_for_string( check_str_after_submit )
|
||||
except:
|
||||
self.library_wait( library_id )
|
||||
try:
|
||||
self.check_page_for_string( check_str_after_submit )
|
||||
except:
|
||||
self.library_wait( library_id )
|
||||
self.check_page_for_string( check_str_after_submit )
|
||||
self.library_wait( library_id )
|
||||
self.home()
|
||||
def act_on_multiple_datasets( self, cntrller, library_id, do_action, ldda_ids='', check_str1='' ):
|
||||
def act_on_multiple_datasets( self, cntrller, library_id, do_action, ldda_ids='', strings_displayed=[] ):
|
||||
# Can't use the ~/library_admin/libraries form as twill barfs on it so we'll simulate the form submission
|
||||
# by going directly to the form action
|
||||
self.visit_url( '%s/library_common/act_on_multiple_datasets?cntrller=%s&library_id=%s&ldda_ids=%s&do_action=%s' \
|
||||
% ( self.url, cntrller, library_id, ldda_ids, do_action ) )
|
||||
if check_str1:
|
||||
self.check_page_for_string( check_str1 )
|
||||
for check_str in strings_displayed:
|
||||
self.check_page_for_string( check_str )
|
||||
def download_archive_of_library_files( self, cntrller, library_id, ldda_ids, format ):
|
||||
self.home()
|
||||
# Here it would be ideal to have twill set form values and submit the form, but
|
||||
@@ -2193,11 +2033,10 @@ class TwillTestCase( unittest.TestCase ):
|
||||
check_str = "Library '%s' and all of its contents have been purged" % library_name
|
||||
self.check_page_for_string( check_str )
|
||||
self.home()
|
||||
def library_wait( self, library_id, cntrller='library_admin', maxiter=20 ):
|
||||
def library_wait( self, library_id, cntrller='library_admin', maxiter=60 ):
|
||||
"""Waits for the tools to finish"""
|
||||
count = 0
|
||||
sleep_amount = 1
|
||||
self.home()
|
||||
while count < maxiter:
|
||||
count += 1
|
||||
self.visit_url( "%s/library_common/browse_library?cntrller=%s&id=%s" % ( self.url, cntrller, library_id ) )
|
||||
@@ -2210,6 +2049,6 @@ class TwillTestCase( unittest.TestCase ):
|
||||
self.assertNotEqual(count, maxiter)
|
||||
|
||||
# Tests associated with tags
|
||||
def add_tag( self, item_id, item_class, context, new_tag, check_str='' ):
|
||||
def add_tag( self, item_id, item_class, context, new_tag ):
|
||||
self.visit_url( "%s/tag/add_tag_async?item_id=%s&item_class=%s&context=%s&new_tag=%s" % \
|
||||
( self.url, item_id, item_class, context, new_tag ) )
|
||||
|
||||
@@ -281,12 +281,12 @@ class TestDataSecurity( TwillTestCase ):
|
||||
group_ids = []
|
||||
for uga in admin_user.groups:
|
||||
group_ids.append( str( uga.group_id ) )
|
||||
check_str = "User '%s' has been updated with %d associated roles and %d associated groups" % \
|
||||
( admin_user.email, len( role_ids ), len( group_ids ) )
|
||||
strings_displayed = [ "User '%s' has been updated with %d associated roles and %d associated groups" % \
|
||||
( admin_user.email, len( role_ids ), len( group_ids ) ) ]
|
||||
self.manage_roles_and_groups_for_user( self.security.encode_id( admin_user.id ),
|
||||
in_role_ids=role_ids,
|
||||
in_group_ids=group_ids,
|
||||
check_str=check_str )
|
||||
strings_displayed=strings_displayed )
|
||||
refresh( admin_user )
|
||||
# admin_user should now be associated with 4 roles: private, role_one, role_two, role_three
|
||||
if len( admin_user.roles ) != 4:
|
||||
@@ -295,7 +295,7 @@ class TestDataSecurity( TwillTestCase ):
|
||||
def test_055_mark_group_deleted( self ):
|
||||
"""Testing marking a group as deleted"""
|
||||
# Logged in as admin_user
|
||||
self.browse_groups( check_str1=group_two.name )
|
||||
self.browse_groups( strings_displayed=[ group_two.name ] )
|
||||
self.mark_group_deleted( self.security.encode_id( group_two.id ), group_two.name )
|
||||
refresh( group_two )
|
||||
if not group_two.deleted:
|
||||
@@ -316,7 +316,7 @@ class TestDataSecurity( TwillTestCase ):
|
||||
"""Testing marking a role as deleted"""
|
||||
# Logged in as admin_user
|
||||
self.home()
|
||||
self.browse_roles( check_str1=role_two.name )
|
||||
self.browse_roles( strings_displayed=[ role_two.name ] )
|
||||
self.mark_role_deleted( self.security.encode_id( role_two.id ), role_two.name )
|
||||
refresh( role_two )
|
||||
if not role_two.deleted:
|
||||
|
||||
@@ -55,12 +55,11 @@ class TestDataSecurity( TwillTestCase ):
|
||||
raise AssertionError( 'The DefaultHistoryPermission.action for history id %d is "%s", but it should be "%s"' \
|
||||
% ( latest_history.id, dhp.action, galaxy.model.Dataset.permitted_actions.DATASET_MANAGE_PERMISSIONS.action ) )
|
||||
self.manage_roles_and_groups_for_user( self.security.encode_id( admin_user.id ),
|
||||
check_str=admin_user.email )
|
||||
strings_displayed=[ admin_user.email ] )
|
||||
# Try deleting the admin_user's private role
|
||||
check_str = "You cannot eliminate a user's private role association."
|
||||
self.manage_roles_and_groups_for_user( self.security.encode_id( admin_user.id ),
|
||||
out_role_ids=str( admin_user_private_role.id ),
|
||||
check_str=check_str )
|
||||
strings_displayed = [ "You cannot eliminate a user's private role association." ] )
|
||||
def test_010_private_role_creation_and_default_history_permissions( self ):
|
||||
"""Testing private role creation and changing DefaultHistoryPermissions for new histories"""
|
||||
# Logged in as admin_user
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
import galaxy.model
|
||||
from galaxy.model.orm import *
|
||||
from galaxy.model.mapping import context as sa_session
|
||||
from base.twilltestcase import *
|
||||
from base.test_db_util import *
|
||||
|
||||
not_logged_in_as_admin_security_msg = 'You must be logged in as an administrator to access this feature.'
|
||||
logged_in_as_admin_security_msg = 'You must be an administrator to access this feature.'
|
||||
not_logged_in_security_msg = 'You must be logged in to create/submit sequencing requests'
|
||||
form_one_name = "Request Form"
|
||||
form_two_name = "Sample Form"
|
||||
request_type_name = 'Test Requestype'
|
||||
sample_states = [ ( 'New', 'Sample entered into the system' ),
|
||||
( 'Received', 'Sample tube received' ),
|
||||
( 'Done', 'Sequence run complete' ) ]
|
||||
@@ -23,17 +16,6 @@ address_dict = dict( short_desc="Office",
|
||||
country="United+Kingdom",
|
||||
phone="007-007-0007" )
|
||||
|
||||
def get_latest_form(form_name):
|
||||
fdc_list = sa_session.query( galaxy.model.FormDefinitionCurrent ) \
|
||||
.filter( galaxy.model.FormDefinitionCurrent.table.c.deleted==False ) \
|
||||
.order_by( galaxy.model.FormDefinitionCurrent.table.c.create_time.desc() )
|
||||
for fdc in fdc_list:
|
||||
sa_session.refresh( fdc )
|
||||
sa_session.refresh( fdc.latest_form )
|
||||
if form_name == fdc.latest_form.name:
|
||||
return fdc.latest_form
|
||||
return None
|
||||
|
||||
class TestFormsAndRequests( TwillTestCase ):
|
||||
def test_000_initiate_users( self ):
|
||||
"""Ensuring all required user accounts exist"""
|
||||
@@ -113,12 +95,13 @@ class TestFormsAndRequests( TwillTestCase ):
|
||||
self.logout()
|
||||
self.login( email=admin_user.email )
|
||||
# create a form
|
||||
global form_one_name
|
||||
name = "Request Form"
|
||||
desc = "This is Form One's description"
|
||||
formtype = galaxy.model.FormDefinition.types.REQUEST
|
||||
self.create_form( name=form_one_name, desc=desc, formtype=formtype, num_fields=0 )
|
||||
self.create_form( name=name, desc=desc, formtype=formtype, num_fields=0 )
|
||||
# Get the form_definition object for later tests
|
||||
form_one = get_latest_form(form_one_name)
|
||||
global form_one
|
||||
form_one = get_form( name )
|
||||
assert form_one is not None, 'Problem retrieving form named "%s" from the database' % name
|
||||
# edit form & add few more fields
|
||||
new_name = "Request Form (Renamed)"
|
||||
@@ -128,7 +111,7 @@ class TestFormsAndRequests( TwillTestCase ):
|
||||
self.visit_page( 'forms/manage' )
|
||||
self.check_page_for_string( new_name )
|
||||
self.check_page_for_string( new_desc )
|
||||
form_one_name = new_name
|
||||
form_one = get_form( new_name )
|
||||
def test_015_add_form_fields( self ):
|
||||
"""Testing adding fields to a form definition"""
|
||||
fields = [dict(name='Test field name one',
|
||||
@@ -144,58 +127,62 @@ class TestFormsAndRequests( TwillTestCase ):
|
||||
desc='Test field description three',
|
||||
type='TextField',
|
||||
required='required')]
|
||||
form_one = get_latest_form(form_one_name)
|
||||
self.form_add_field(form_one.current.id, form_one.name, form_one.desc, form_one.type,
|
||||
field_index=len(form_one.fields), fields=fields)
|
||||
form_one_latest = get_latest_form(form_one_name)
|
||||
assert len(form_one_latest.fields) == len(form_one.fields)+len(fields)
|
||||
self.form_add_field( form_one.current.id,
|
||||
form_one.name,
|
||||
form_one.desc,
|
||||
form_one.type,
|
||||
field_index=len( form_one.fields ),
|
||||
fields=fields )
|
||||
form_one_latest = get_form( form_one.name )
|
||||
assert len( form_one_latest.fields ) == len( form_one.fields ) + len( fields )
|
||||
def test_020_create_sample_form( self ):
|
||||
"""Testing creating another form (for samples)"""
|
||||
global form_two_name
|
||||
name = "Sample Form"
|
||||
desc = "This is Form Two's description"
|
||||
formtype = galaxy.model.FormDefinition.types.SAMPLE
|
||||
form_layout_name = 'Layout Grid One'
|
||||
self.create_form( name=form_two_name, desc=desc, formtype=formtype, form_layout_name=form_layout_name )
|
||||
self.create_form( name=name, desc=desc, formtype=formtype, form_layout_name=form_layout_name )
|
||||
global form_two
|
||||
form_two = get_form( name )
|
||||
assert form_two is not None, "Error retrieving form %s from db" % name
|
||||
self.home()
|
||||
self.visit_page( 'forms/manage' )
|
||||
self.check_page_for_string( form_two_name )
|
||||
self.check_page_for_string( form_two.name )
|
||||
self.check_page_for_string( desc )
|
||||
self.check_page_for_string( formtype )
|
||||
def test_025_create_request_type( self ):
|
||||
"""Testing creating a new requestype"""
|
||||
request_form = get_latest_form(form_one_name)
|
||||
sample_form = get_latest_form(form_two_name)
|
||||
self.create_request_type(request_type_name, "test sequencer configuration",
|
||||
str(request_form.id), str(sample_form.id), sample_states )
|
||||
global request_type
|
||||
request_type = sa_session.query( galaxy.model.RequestType ) \
|
||||
.filter( and_( galaxy.model.RequestType.table.c.name==request_type_name ) ) \
|
||||
.order_by( desc( galaxy.model.RequestType.table.c.create_time ) ) \
|
||||
.first()
|
||||
assert request_type is not None, 'Problem retrieving sequencer configuration named "%s" from the database' % request_type_name
|
||||
request_form = get_form( form_one.name )
|
||||
sample_form = get_form( form_two.name )
|
||||
name = 'Test Requestype'
|
||||
self.create_request_type( name, "test sequencer configuration", str( request_form.id ), str( sample_form.id ), sample_states )
|
||||
global request_type1
|
||||
request_type1 = get_request_type_by_name( name )
|
||||
assert request_type1 is not None, 'Problem retrieving sequencer configuration named "%s" from the database' % name
|
||||
# Set permissions
|
||||
permissions_in = [ k for k, v in galaxy.model.RequestType.permitted_actions.items() ]
|
||||
permissions_out = []
|
||||
# Role one members are: admin_user, regular_user1, regular_user3. Each of these users will be permitted for
|
||||
# REQUEST_TYPE_ACCESS on this request_type
|
||||
self.request_type_permissions(self.security.encode_id( request_type.id ),
|
||||
request_type.name,
|
||||
str( role_one.id ),
|
||||
permissions_in,
|
||||
permissions_out )
|
||||
# Make sure the request_type is not accessible by regular_user2 since regular_user2 does not have Role1.
|
||||
self.request_type_permissions( self.security.encode_id( request_type1.id ),
|
||||
request_type1.name,
|
||||
str( role_one.id ),
|
||||
permissions_in,
|
||||
permissions_out )
|
||||
# Make sure the request_type1 is not accessible by regular_user2 since regular_user2 does not have Role1.
|
||||
self.logout()
|
||||
self.login( email=regular_user2.email )
|
||||
self.visit_url( '%s/requests_common/new?cntrller=requests&select_request_type=True' % self.url )
|
||||
try:
|
||||
self.check_page_for_string( 'There are no sequencer configurations created for a new request.' )
|
||||
raise AssertionError, 'The request_type %s is accessible by %s when it should be restricted' % ( request_type.name, regular_user2.email )
|
||||
raise AssertionError, 'The request_type %s is accessible by %s when it should be restricted' % ( request_type1.name, regular_user2.email )
|
||||
except:
|
||||
pass
|
||||
self.logout()
|
||||
self.login( email=admin_user.email )
|
||||
def test_030_create_address_and_library( self ):
|
||||
"""Testing address & library creation"""
|
||||
# ( 9/17/10 placed by gvk ) Hey, RC, why is this test here? The library is never used later in this script.
|
||||
# first create a library for the request so that it can be submitted later
|
||||
name = "TestLib001"
|
||||
description = "TestLib001 description"
|
||||
@@ -247,23 +234,21 @@ class TestFormsAndRequests( TwillTestCase ):
|
||||
self.logout()
|
||||
self.login( email=regular_user1.email )
|
||||
self.add_user_address( regular_user1.id, address_dict )
|
||||
global user_address
|
||||
user_address = get_user_address( regular_user1, address_dict[ 'short_desc' ] )
|
||||
global user_address1
|
||||
user_address1 = get_user_address( regular_user1, address_dict[ 'short_desc' ] )
|
||||
def test_035_create_request( self ):
|
||||
"""Testing creating, editing and submitting a request as a regular user"""
|
||||
# login as a regular user
|
||||
self.logout()
|
||||
self.login( email=regular_user1.email )
|
||||
# set field values
|
||||
fields = ['option1', str(user_address.id), 'field three value']
|
||||
fields = ['option1', str(user_address1.id), 'field three value']
|
||||
# create the request
|
||||
request_name, request_desc = 'Request One', 'Request One Description'
|
||||
self.create_request(request_type.id, request_name, request_desc, fields)
|
||||
name = 'Request One'
|
||||
desc = 'Request One Description'
|
||||
self.create_request(request_type1.id, name, desc, fields)
|
||||
global request_one
|
||||
request_one = sa_session.query( galaxy.model.Request ) \
|
||||
.filter( and_( galaxy.model.Request.table.c.name==request_name,
|
||||
galaxy.model.Request.table.c.deleted==False ) ) \
|
||||
.first()
|
||||
request_one = get_request_by_name( name )
|
||||
# check if the request's state is now set to 'new'
|
||||
assert request_one.state is not request_one.states.NEW, "The state of the request '%s' should be set to '%s'" \
|
||||
% ( request_one.name, request_one.states.NEW )
|
||||
@@ -273,15 +258,15 @@ class TestFormsAndRequests( TwillTestCase ):
|
||||
# add samples to this request
|
||||
self.add_samples( request_one.id, request_one.name, samples )
|
||||
# edit this request
|
||||
fields = ['option2', str(user_address.id), 'field three value (edited)']
|
||||
fields = ['option2', str(user_address1.id), 'field three value (edited)']
|
||||
self.edit_request(request_one.id, request_one.name, request_one.name+' (Renamed)',
|
||||
request_one.desc+' (Re-described)', fields)
|
||||
sa_session.refresh( request_one )
|
||||
refresh( request_one )
|
||||
# check if the request is showing in the 'new' filter
|
||||
self.check_request_grid(state=request_one.states.NEW, request_name=request_one.name)
|
||||
# submit the request
|
||||
self.submit_request( request_one.id, request_one.name )
|
||||
sa_session.refresh( request_one )
|
||||
refresh( request_one )
|
||||
# check if the request is showing in the 'submitted' filter
|
||||
self.check_request_grid(state=request_one.states.SUBMITTED, request_name=request_one.name)
|
||||
# check if the request's state is now set to 'submitted'
|
||||
@@ -301,10 +286,10 @@ class TestFormsAndRequests( TwillTestCase ):
|
||||
self.add_bar_codes( request_one.id, request_one.name, bar_codes, request_one.samples )
|
||||
# change the states of all the samples of this request
|
||||
for sample in request_one.samples:
|
||||
self.change_sample_state( request_one.id, request_one.name, sample.name, sample.id, request_type.states[1].id, request_type.states[1].name )
|
||||
self.change_sample_state( request_one.id, request_one.name, sample.name, sample.id, request_type.states[2].id, request_type.states[2].name )
|
||||
self.change_sample_state( request_one.id, request_one.name, sample.name, sample.id, request_type1.states[1].id, request_type1.states[1].name )
|
||||
self.change_sample_state( request_one.id, request_one.name, sample.name, sample.id, request_type1.states[2].id, request_type1.states[2].name )
|
||||
self.home()
|
||||
sa_session.refresh( request_one )
|
||||
refresh( request_one )
|
||||
self.logout()
|
||||
self.login( email=regular_user1.email )
|
||||
# check if the request's state is now set to 'complete'
|
||||
@@ -315,19 +300,16 @@ class TestFormsAndRequests( TwillTestCase ):
|
||||
"""Testing creating and submitting a request as an admin on behalf of a regular user"""
|
||||
self.logout()
|
||||
self.login( email=admin_user.email )
|
||||
request_name = "RequestTwo"
|
||||
name = "RequestTwo"
|
||||
# TODO: fix this test so it is no longer simulated.
|
||||
# simulate request creation
|
||||
url_str = '%s/requests_common/new?cntrller=requests_admin&create_request_button=Save&select_request_type=%i&select_user=%i&name=%s&refresh=True&field_2=%s&field_0=%s&field_1=%i' \
|
||||
% ( self.url, request_type.id, regular_user1.id, request_name, "field_2_value", 'option1', user_address.id )
|
||||
print url_str
|
||||
% ( self.url, request_type1.id, regular_user1.id, name, "field_2_value", 'option1', user_address1.id )
|
||||
self.home()
|
||||
self.visit_url( url_str )
|
||||
self.check_page_for_string( "The new request named <b>%s</b> has been created" % request_name )
|
||||
self.check_page_for_string( "The new request named <b>%s</b> has been created" % name )
|
||||
global request_two
|
||||
request_two = sa_session.query( galaxy.model.Request ) \
|
||||
.filter( and_( galaxy.model.Request.table.c.name==request_name,
|
||||
galaxy.model.Request.table.c.deleted==False ) ) \
|
||||
.first()
|
||||
request_two = get_request_by_name( name )
|
||||
# check if the request is showing in the 'new' filter
|
||||
self.check_request_admin_grid(state=request_two.states.NEW, request_name=request_two.name)
|
||||
# check if the request's state is now set to 'new'
|
||||
@@ -340,7 +322,7 @@ class TestFormsAndRequests( TwillTestCase ):
|
||||
self.add_samples( request_two.id, request_two.name, samples )
|
||||
# submit the request
|
||||
self.submit_request_as_admin( request_two.id, request_two.name )
|
||||
sa_session.refresh( request_two )
|
||||
refresh( request_two )
|
||||
# check if the request is showing in the 'submitted' filter
|
||||
self.check_request_admin_grid(state=request_two.states.SUBMITTED, request_name=request_two.name)
|
||||
# check if the request's state is now set to 'submitted'
|
||||
@@ -354,7 +336,7 @@ class TestFormsAndRequests( TwillTestCase ):
|
||||
self.logout()
|
||||
self.login( email=admin_user.email )
|
||||
self.reject_request( request_two.id, request_two.name, "Rejection test comment" )
|
||||
sa_session.refresh( request_two )
|
||||
refresh( request_two )
|
||||
# check if the request is showing in the 'rejected' filter
|
||||
self.check_request_admin_grid(state=request_two.states.REJECTED, request_name=request_two.name)
|
||||
# check if the request's state is now set to 'submitted'
|
||||
@@ -363,14 +345,31 @@ class TestFormsAndRequests( TwillTestCase ):
|
||||
def test_055_reset_data_for_later_test_runs( self ):
|
||||
"""Reseting data to enable later test runs to pass"""
|
||||
# Logged in as admin_user
|
||||
# remove the request_type permissions
|
||||
rt_actions = sa_session.query( galaxy.model.RequestTypePermissions ) \
|
||||
.filter(and_(galaxy.model.RequestTypePermissions.table.c.request_type_id==request_type.id) ) \
|
||||
.order_by( desc( galaxy.model.RequestTypePermissions.table.c.create_time ) ) \
|
||||
.all()
|
||||
for a in rt_actions:
|
||||
sa_session.delete( a )
|
||||
sa_session.flush()
|
||||
##################
|
||||
# Delete request_type permissions
|
||||
##################
|
||||
for request_type in [ request_type1 ]:
|
||||
delete_request_type_permissions( request_type.id )
|
||||
##################
|
||||
# Mark all request_types deleted
|
||||
##################
|
||||
for request_type in [ request_type1 ]:
|
||||
mark_obj_deleted( request_type )
|
||||
##################
|
||||
# Mark all requests deleted
|
||||
##################
|
||||
for request in [ request_one, request_two ]:
|
||||
mark_obj_deleted( request )
|
||||
##################
|
||||
# Mark all forms deleted
|
||||
##################
|
||||
for form in [ form_one, form_two ]:
|
||||
self.mark_form_deleted( self.security.encode_id( form.current.id ) )
|
||||
##################
|
||||
# Mark all user_addresses deleted
|
||||
##################
|
||||
for user_address in [ user_address1 ]:
|
||||
mark_obj_deleted( user_address )
|
||||
##################
|
||||
# Purge all libraries
|
||||
##################
|
||||
@@ -382,22 +381,20 @@ class TestFormsAndRequests( TwillTestCase ):
|
||||
item_type='library' )
|
||||
self.purge_library( self.security.encode_id( library.id ), library.name )
|
||||
##################
|
||||
# Eliminate all non-private roles
|
||||
# Delete all non-private roles
|
||||
##################
|
||||
for role in [ role_one, role_two ]:
|
||||
self.mark_role_deleted( self.security.encode_id( role.id ), role.name )
|
||||
self.purge_role( self.security.encode_id( role.id ), role.name )
|
||||
# Manually delete the role from the database
|
||||
sa_session.refresh( role )
|
||||
sa_session.delete( role )
|
||||
sa_session.flush()
|
||||
refresh( role )
|
||||
delete( role )
|
||||
##################
|
||||
# Eliminate all groups
|
||||
# Delete all groups
|
||||
##################
|
||||
for group in [ group_one ]:
|
||||
self.mark_group_deleted( self.security.encode_id( group.id ), group.name )
|
||||
self.purge_group( self.security.encode_id( group.id ), group.name )
|
||||
# Manually delete the group from the database
|
||||
refresh( group )
|
||||
sa_session.delete( group )
|
||||
sa_session.flush()
|
||||
delete( group )
|
||||
|
||||
@@ -120,17 +120,17 @@ class TestHistory( TwillTestCase ):
|
||||
# Since we deleted the current history, make sure the history frame was refreshed
|
||||
self.check_history_for_string( 'Your history is empty.' )
|
||||
try:
|
||||
self.view_stored_active_histories( check_str=history1.name )
|
||||
self.view_stored_active_histories( strings_displayed=[ history1.name ] )
|
||||
raise AssertionError, "History %s is displayed in the active history list after it was deleted" % history1.name
|
||||
except:
|
||||
pass
|
||||
self.view_stored_deleted_histories( check_str=history1.name )
|
||||
self.view_stored_deleted_histories( strings_displayed=[ history1.name ] )
|
||||
try:
|
||||
self.view_stored_active_histories( check_str=history2.name )
|
||||
self.view_stored_active_histories( strings_displayed=[ history2.name ] )
|
||||
raise AssertionError, "History %s is displayed in the active history list after it was deleted" % history2.name
|
||||
except:
|
||||
pass
|
||||
self.view_stored_deleted_histories( check_str=history2.name )
|
||||
self.view_stored_deleted_histories( strings_displayed=[ history2.name ] )
|
||||
sa_session.refresh( history1 )
|
||||
if not history1.deleted:
|
||||
raise AssertionError, "Problem deleting history id %d" % history1.id
|
||||
@@ -165,25 +165,25 @@ class TestHistory( TwillTestCase ):
|
||||
# Logged in as admin_user
|
||||
# Test sharing an empty history - current history is history3
|
||||
self.share_current_history( regular_user1.email,
|
||||
check_str=history3.name,
|
||||
check_str_after_submit='You cannot share an empty history.' )
|
||||
strings_displayed=[ history3.name ],
|
||||
strings_displayed_after_submit=[ 'You cannot share an empty history.' ] )
|
||||
# Make history3 sharable by adding a dataset
|
||||
self.upload_file( '1.bed', dbkey='hg18' )
|
||||
# Current history is no longer empty
|
||||
self.history_options( user=True, active_datasets=True, activatable_datasets=True )
|
||||
# Test sharing history3 with yourself
|
||||
self.share_current_history( admin_user.email,
|
||||
check_str=history3.name,
|
||||
check_str_after_submit='You cannot send histories to yourself.' )
|
||||
strings_displayed=[ history3.name ],
|
||||
strings_displayed_after_submit=[ 'You cannot send histories to yourself.' ] )
|
||||
# Share history3 with 1 valid user
|
||||
self.share_current_history( regular_user1.email,
|
||||
check_str=history3.name )
|
||||
strings_displayed=[ history3.name ] )
|
||||
# Check out list of histories to make sure history3 was shared
|
||||
self.view_stored_active_histories( check_str='operation=share' )
|
||||
self.view_stored_active_histories( strings_displayed=[ 'operation=share' ] )
|
||||
# Make history3 accessible via link.
|
||||
self.make_accessible_via_link( self.security.encode_id( history3.id ),
|
||||
check_str='Make History Accessible via Link',
|
||||
check_str_after_submit='Anyone can view and import this history' )
|
||||
strings_displayed=[ 'Make History Accessible via Link' ],
|
||||
strings_displayed_after_submit=[ 'Anyone can view and import this history' ] )
|
||||
# Make sure history3 is now accessible.
|
||||
sa_session.refresh( history3 )
|
||||
if not history3.importable:
|
||||
@@ -191,27 +191,27 @@ class TestHistory( TwillTestCase ):
|
||||
# Try importing history3
|
||||
self.import_history_via_url( self.security.encode_id( history3.id ),
|
||||
admin_user.email,
|
||||
check_str_after_submit='You cannot import your own history.' )
|
||||
strings_displayed_after_submit=[ 'You cannot import your own history.' ] )
|
||||
# Disable access via link for history3.
|
||||
self.disable_access_via_link( self.security.encode_id( history3.id ),
|
||||
check_str='Anyone can view and import this history',
|
||||
check_str_after_submit='Make History Accessible via Link' )
|
||||
strings_displayed=[ 'Anyone can view and import this history' ],
|
||||
strings_displayed_after_submit=[ 'Make History Accessible via Link' ] )
|
||||
# Try importing history3 after disabling access via link. To do this, need to login as regular user 2, who cannot access
|
||||
# history via sharing or via link.
|
||||
self.logout()
|
||||
self.login( email=regular_user2.email )
|
||||
self.import_history_via_url( self.security.encode_id( history3.id ),
|
||||
admin_user.email,
|
||||
check_str_after_submit='History is not accessible to current user' )
|
||||
strings_displayed_after_submit=[ 'History is not accessible to current user' ] )
|
||||
self.logout()
|
||||
self.login( email=admin_user.email )
|
||||
# Test sharing history3 with an invalid user
|
||||
self.share_current_history( 'jack@jill.com',
|
||||
check_str_after_submit='jack@jill.com is not a valid Galaxy user.' )
|
||||
strings_displayed_after_submit=[ 'jack@jill.com is not a valid Galaxy user.' ] )
|
||||
def test_025_delete_shared_current_history( self ):
|
||||
"""Testing deleting the current history after it was shared"""
|
||||
# Logged in as admin_user
|
||||
self.delete_current_history( check_str="History (%s) has been shared with others, unshare it before deleting it." % history3.name )
|
||||
self.delete_current_history( strings_displayed=[ "History (%s) has been shared with others, unshare it before deleting it." % history3.name ] )
|
||||
def test_030_clone_shared_history( self ):
|
||||
"""Testing cloning a shared history"""
|
||||
# logged in as admin user
|
||||
@@ -220,10 +220,10 @@ class TestHistory( TwillTestCase ):
|
||||
# Shared history3 affects history options
|
||||
self.history_options( user=True, histories_shared_by_others=True )
|
||||
# Shared history3 should be in regular_user1's list of shared histories
|
||||
self.view_shared_histories( check_str=history3.name, check_str2=admin_user.email )
|
||||
self.view_shared_histories( strings_displayed=[ history3.name, admin_user.email ] )
|
||||
self.clone_history( self.security.encode_id( history3.id ),
|
||||
'activatable',
|
||||
check_str_after_submit='is now included in your previously stored histories.' )
|
||||
strings_displayed_after_submit=[ 'is now included in your previously stored histories.' ] )
|
||||
global history3_clone1
|
||||
history3_clone1 = sa_session.query( galaxy.model.History ) \
|
||||
.filter( and_( galaxy.model.History.table.c.deleted==False,
|
||||
@@ -232,8 +232,8 @@ class TestHistory( TwillTestCase ):
|
||||
.first()
|
||||
assert history3_clone1 is not None, "Problem retrieving history3_clone1 from database"
|
||||
# Check list of histories to make sure shared history3 was cloned
|
||||
check_str = "Clone of '%s' shared by '%s'" % ( history3.name, admin_user.email )
|
||||
self.view_stored_active_histories( check_str=check_str )
|
||||
strings_displayed=[ "Clone of '%s' shared by '%s'" % ( history3.name, admin_user.email ) ]
|
||||
self.view_stored_active_histories( strings_displayed=strings_displayed )
|
||||
def test_035_clone_current_history( self ):
|
||||
"""Testing cloning the current history"""
|
||||
# logged in as regular_user1
|
||||
@@ -258,7 +258,7 @@ class TestHistory( TwillTestCase ):
|
||||
# Test cloning activatable datasets
|
||||
self.clone_history( self.security.encode_id( history3.id ),
|
||||
'activatable',
|
||||
check_str_after_submit='is now included in your previously stored histories.' )
|
||||
strings_displayed_after_submit=['is now included in your previously stored histories.' ] )
|
||||
global history3_clone2
|
||||
history3_clone2 = sa_session.query( galaxy.model.History ) \
|
||||
.filter( and_( galaxy.model.History.table.c.deleted==False,
|
||||
@@ -267,7 +267,7 @@ class TestHistory( TwillTestCase ):
|
||||
.first()
|
||||
assert history3_clone2 is not None, "Problem retrieving history3_clone2 from database"
|
||||
# Check list of histories to make sure shared history3 was cloned
|
||||
self.view_stored_active_histories( check_str="Clone of '%s'" % history3.name )
|
||||
self.view_stored_active_histories( strings_displayed=[ "Clone of '%s'" % history3.name ] )
|
||||
# Switch to the cloned history to make sure activatable datasets were cloned
|
||||
self.switch_history( id=self.security.encode_id( history3_clone2.id ), name=history3_clone2.name )
|
||||
hda_2_bed = sa_session.query( galaxy.model.HistoryDatasetAssociation ) \
|
||||
@@ -288,7 +288,7 @@ class TestHistory( TwillTestCase ):
|
||||
# Test cloning only active datasets
|
||||
self.clone_history( self.security.encode_id( history3.id ),
|
||||
'active',
|
||||
check_str_after_submit='is now included in your previously stored histories.' )
|
||||
strings_displayed_after_submit=[ 'is now included in your previously stored histories.' ] )
|
||||
global history3_clone3
|
||||
history3_clone3 = sa_session.query( galaxy.model.History ) \
|
||||
.filter( and_( galaxy.model.History.table.c.deleted==False,
|
||||
@@ -297,7 +297,7 @@ class TestHistory( TwillTestCase ):
|
||||
.first()
|
||||
assert history3_clone3 is not None, "Problem retrieving history3_clone3 from database"
|
||||
# Check list of histories to make sure shared history3 was cloned
|
||||
self.view_stored_active_histories( check_str="Clone of '%s'" % history3.name )
|
||||
self.view_stored_active_histories( strings_displayed = ["Clone of '%s'" % history3.name ] )
|
||||
# Switch to the cloned history to make sure activatable datasets were cloned
|
||||
self.switch_history( id=self.security.encode_id( history3_clone3.id ) )
|
||||
# Make sure the deleted datasets are NOT included in the cloned history
|
||||
@@ -327,16 +327,15 @@ class TestHistory( TwillTestCase ):
|
||||
emails = '%s,%s' % ( regular_user2.email, regular_user3.email )
|
||||
self.share_histories_with_users( ids,
|
||||
emails,
|
||||
check_str1='Share 2 histories',
|
||||
check_str2=history4.name )
|
||||
strings_displayed=[ 'Share 2 histories', history4.name ] )
|
||||
self.logout()
|
||||
self.login( email=regular_user2.email )
|
||||
# Shared history3 should be in regular_user2's list of shared histories
|
||||
self.view_shared_histories( check_str=history3.name, check_str2=admin_user.email )
|
||||
self.view_shared_histories( strings_displayed=[ history3.name, admin_user.email ] )
|
||||
self.logout()
|
||||
self.login( email=regular_user3.email )
|
||||
# Shared history3 should be in regular_user3's list of shared histories
|
||||
self.view_shared_histories( check_str=history3.name, check_str2=admin_user.email )
|
||||
self.view_shared_histories( cstrings_displayed=[ history3.name, admin_user.email ] )
|
||||
"""
|
||||
def test_045_change_permissions_on_current_history( self ):
|
||||
"""Testing changing permissions on the current history"""
|
||||
@@ -394,19 +393,19 @@ class TestHistory( TwillTestCase ):
|
||||
def test_050_sharing_restricted_history_by_making_datasets_public( self ):
|
||||
"""Testing sharing a restricted history by making the datasets public"""
|
||||
# Logged in as admin_user
|
||||
action_check_str = 'The following datasets can be shared with %s by updating their permissions' % regular_user1.email
|
||||
action_strings_displayed = [ 'The following datasets can be shared with %s by updating their permissions' % regular_user1.email ]
|
||||
# Current history is history5
|
||||
self.share_current_history( regular_user1.email,
|
||||
action='public',
|
||||
action_check_str=action_check_str )
|
||||
action_strings_displayed=action_strings_displayed )
|
||||
self.logout()
|
||||
self.login( email=regular_user1.email )
|
||||
# Shared history5 should be in regular_user1's list of shared histories
|
||||
self.view_shared_histories( check_str=history5.name, check_str2=admin_user.email )
|
||||
self.view_shared_histories( strings_displayed=[ history5.name, admin_user.email ] )
|
||||
# Clone restricted history5
|
||||
self.clone_history( self.security.encode_id( history5.id ),
|
||||
'activatable',
|
||||
check_str_after_submit='is now included in your previously stored histories.' )
|
||||
strings_displayed_after_submit=[ 'is now included in your previously stored histories.' ] )
|
||||
global history5_clone1
|
||||
history5_clone1 = sa_session.query( galaxy.model.History ) \
|
||||
.filter( and_( galaxy.model.History.table.c.deleted==False,
|
||||
@@ -415,7 +414,7 @@ class TestHistory( TwillTestCase ):
|
||||
.first()
|
||||
assert history5_clone1 is not None, "Problem retrieving history5_clone1 from database"
|
||||
# Check list of histories to make sure shared history5 was cloned
|
||||
self.view_stored_active_histories( check_str="Clone of '%s'" % history5.name )
|
||||
self.view_stored_active_histories( strings_displayed=[ "Clone of '%s'" % history5.name ] )
|
||||
# Make sure the dataset is accessible
|
||||
self.switch_history( id=self.security.encode_id( history5_clone1.id ), name=history5_clone1.name )
|
||||
self.check_history_for_string( 'chr1' )
|
||||
@@ -426,11 +425,10 @@ class TestHistory( TwillTestCase ):
|
||||
# At this point, history5 should have 1 item, 1.bed, which is public. We'll add another
|
||||
# item which will be private to admin_user due to the permissions on history5
|
||||
self.upload_file( '2.bed', dbkey='hg18' )
|
||||
check_str_after_submit = 'The following datasets can be shared with %s with no changes' % regular_user2.email
|
||||
check_str_after_submit2 = 'The following datasets can be shared with %s by updating their permissions' % regular_user2.email
|
||||
strings_displayed_after_submit = [ 'The following datasets can be shared with %s with no changes' % regular_user2.email,
|
||||
'The following datasets can be shared with %s by updating their permissions' % regular_user2.email ]
|
||||
self.share_current_history( regular_user2.email,
|
||||
check_str_after_submit=check_str_after_submit,
|
||||
check_str_after_submit2=check_str_after_submit2,
|
||||
strings_displayed_after_submit=strings_displayed_after_submit,
|
||||
action='private' )
|
||||
# We should now have a new sharing role
|
||||
global sharing_role
|
||||
@@ -460,11 +458,11 @@ class TestHistory( TwillTestCase ):
|
||||
self.logout()
|
||||
self.login( email=regular_user2.email )
|
||||
# Shared history5 should be in regular_user2's list of shared histories
|
||||
self.view_shared_histories( check_str=history5.name, check_str2=admin_user.email )
|
||||
self.view_shared_histories( strings_displayed=[ history5.name, admin_user.email ] )
|
||||
# Clone restricted history5
|
||||
self.clone_history( self.security.encode_id( history5.id ),
|
||||
'activatable',
|
||||
check_str_after_submit='is now included in your previously stored histories.' )
|
||||
strings_displayed_after_submit=[ 'is now included in your previously stored histories.' ] )
|
||||
global history5_clone2
|
||||
history5_clone2 = sa_session.query( galaxy.model.History ) \
|
||||
.filter( and_( galaxy.model.History.table.c.deleted==False,
|
||||
@@ -473,7 +471,7 @@ class TestHistory( TwillTestCase ):
|
||||
.first()
|
||||
assert history5_clone2 is not None, "Problem retrieving history5_clone2 from database"
|
||||
# Check list of histories to make sure shared history3 was cloned
|
||||
self.view_stored_active_histories( check_str="Clone of '%s'" % history5.name )
|
||||
self.view_stored_active_histories( strings_displayed=[ "Clone of '%s'" % history5.name ] )
|
||||
# Make sure the dataset is accessible
|
||||
self.switch_history( id=self.security.encode_id( history5_clone2.id ), name=history5_clone2.name )
|
||||
# Make sure both datasets are in the history
|
||||
@@ -491,9 +489,9 @@ class TestHistory( TwillTestCase ):
|
||||
.first()
|
||||
assert hda_2_bed is not None, "Problem retrieving hda_2_bed from database"
|
||||
# Make sure 1.bed is accessible since it is public
|
||||
self.display_history_item( str( hda_1_bed.id ), check_str='chr1' )
|
||||
self.display_history_item( str( hda_1_bed.id ), strings_displayed=[ 'chr1' ] )
|
||||
# Make sure 2.bed is accessible since it is associated with a sharing role
|
||||
self.display_history_item( str( hda_2_bed.id ), check_str='chr1' )
|
||||
self.display_history_item( str( hda_2_bed.id ), strings_displayed=[ 'chr1' ] )
|
||||
# Delete the clone so the next test will be valid
|
||||
self.delete_history( id=self.security.encode_id( history5_clone2.id ) )
|
||||
def test_060_sharing_restricted_history_with_multiple_users_by_changing_no_permissions( self ):
|
||||
@@ -508,8 +506,7 @@ class TestHistory( TwillTestCase ):
|
||||
# We first need to unshare history5 from regular_user2 so that we can re-share it.
|
||||
self.unshare_history( self.security.encode_id( history5.id ),
|
||||
self.security.encode_id( regular_user2.id ),
|
||||
check_str1=regular_user1.email,
|
||||
check_str2=regular_user2.email )
|
||||
strings_displayed=[ regular_user1.email, regular_user2.email ] )
|
||||
# Make sure the history was unshared correctly
|
||||
self.logout()
|
||||
self.login( email=regular_user2.email )
|
||||
@@ -522,22 +519,21 @@ class TestHistory( TwillTestCase ):
|
||||
self.logout()
|
||||
self.login( admin_user.email )
|
||||
email = '%s,%s' % ( regular_user2.email, regular_user3.email )
|
||||
check_str_after_submit = 'The following datasets can be shared with %s with no changes' % email
|
||||
check_str_after_submit2 = 'The following datasets can be shared with %s by updating their permissions' % email
|
||||
strings_displayed_after_submit = [ 'The following datasets can be shared with %s with no changes' % email,
|
||||
'The following datasets can be shared with %s by updating their permissions' % email ]
|
||||
# history5 will be shared with regular_user1, regular_user2 and regular_user3
|
||||
self.share_current_history( email,
|
||||
check_str_after_submit=check_str_after_submit,
|
||||
check_str_after_submit2=check_str_after_submit2,
|
||||
strings_displayed_after_submit=strings_displayed_after_submit,
|
||||
action='share_anyway' )
|
||||
# Check security on clone of history5 for regular_user2
|
||||
self.logout()
|
||||
self.login( email=regular_user2.email )
|
||||
# Shared history5 should be in regular_user2's list of shared histories
|
||||
self.view_shared_histories( check_str=history5.name, check_str2=admin_user.email )
|
||||
self.view_shared_histories( strings_displayed=[ history5.name, admin_user.email ] )
|
||||
# Clone restricted history5
|
||||
self.clone_history( self.security.encode_id( history5.id ),
|
||||
'activatable',
|
||||
check_str_after_submit='is now included in your previously stored histories.' )
|
||||
strings_displayed_after_submit=[ 'is now included in your previously stored histories.' ] )
|
||||
global history5_clone3
|
||||
history5_clone3 = sa_session.query( galaxy.model.History ) \
|
||||
.filter( and_( galaxy.model.History.table.c.deleted==False,
|
||||
@@ -546,7 +542,7 @@ class TestHistory( TwillTestCase ):
|
||||
.first()
|
||||
assert history5_clone3 is not None, "Problem retrieving history5_clone3 from database"
|
||||
# Check list of histories to make sure shared history3 was cloned
|
||||
self.view_stored_active_histories( check_str="Clone of '%s'" % history5.name )
|
||||
self.view_stored_active_histories( strings_displayed=[ "Clone of '%s'" % history5.name ] )
|
||||
# Make sure the dataset is accessible
|
||||
self.switch_history( id=self.security.encode_id( history5_clone3.id ), name=history5_clone3.name )
|
||||
# Make sure both datasets are in the history
|
||||
@@ -564,20 +560,20 @@ class TestHistory( TwillTestCase ):
|
||||
.first()
|
||||
assert hda_2_bed is not None, "Problem retrieving hda_2_bed from database"
|
||||
# Make sure 1.bed is accessible since it is public
|
||||
self.display_history_item( str( hda_1_bed.id ), check_str='chr1' )
|
||||
self.display_history_item( str( hda_1_bed.id ), strings_displayed=[ 'chr1' ] )
|
||||
# Make sure 2.bed is accessible since it is associated with a sharing role
|
||||
self.display_history_item( str( hda_2_bed.id ), check_str='chr1' )
|
||||
self.display_history_item( str( hda_2_bed.id ), strings_displayed=[ 'chr1' ] )
|
||||
# Delete the clone so the next test will be valid
|
||||
self.delete_history( id=self.security.encode_id( history5_clone3.id ) )
|
||||
# Check security on clone of history5 for regular_user3
|
||||
self.logout()
|
||||
self.login( email=regular_user3.email )
|
||||
# Shared history5 should be in regular_user2's list of shared histories
|
||||
self.view_shared_histories( check_str=history5.name, check_str2=admin_user.email )
|
||||
self.view_shared_histories( strings_displayed=[ history5.name, admin_user.email ] )
|
||||
# Clone restricted history5
|
||||
self.clone_history( self.security.encode_id( history5.id ),
|
||||
'activatable',
|
||||
check_str_after_submit='is now included in your previously stored histories.' )
|
||||
strings_displayed_after_submit=[ 'is now included in your previously stored histories.' ] )
|
||||
global history5_clone4
|
||||
history5_clone4 = sa_session.query( galaxy.model.History ) \
|
||||
.filter( and_( galaxy.model.History.table.c.deleted==False,
|
||||
@@ -586,7 +582,7 @@ class TestHistory( TwillTestCase ):
|
||||
.first()
|
||||
assert history5_clone4 is not None, "Problem retrieving history5_clone4 from database"
|
||||
# Check list of histories to make sure shared history3 was cloned
|
||||
self.view_stored_active_histories( check_str="Clone of '%s'" % history5.name )
|
||||
self.view_stored_active_histories( strings_displayed=[ "Clone of '%s'" % history5.name ] )
|
||||
# Make sure the dataset is accessible
|
||||
self.switch_history( id=self.security.encode_id( history5_clone4.id ), name=history5_clone4.name )
|
||||
# Make sure both datasets are in the history
|
||||
@@ -604,10 +600,10 @@ class TestHistory( TwillTestCase ):
|
||||
.first()
|
||||
assert hda_2_bed is not None, "Problem retrieving hda_2_bed from database"
|
||||
# Make sure 1.bed is accessible since it is public
|
||||
self.display_history_item( str( hda_1_bed.id ), check_str='chr1' )
|
||||
self.display_history_item( str( hda_1_bed.id ), strings_displayed=[ 'chr1' ] )
|
||||
# Make sure 2.bed is not accessible since it is protected
|
||||
try:
|
||||
self.display_history_item( str( hda_2_bed.id ), check_str='chr1' )
|
||||
self.display_history_item( str( hda_2_bed.id ), strings_displayed=[ 'chr1' ] )
|
||||
raise AssertionError, "History item 2.bed is accessible by user %s when is should not be" % regular_user3.email
|
||||
except:
|
||||
pass
|
||||
@@ -615,7 +611,7 @@ class TestHistory( TwillTestCase ):
|
||||
# Admin users can view all datasets ( using the history/view feature ), so make sure 2.bed is accessible to the admin
|
||||
self.logout()
|
||||
self.login( email=admin_user.email )
|
||||
self.view_history( str( hda_2_bed.history_id ), check_str='<td>NM_005997_cds_0_0_chr1_147962193_r</td>' )
|
||||
self.view_history( str( hda_2_bed.history_id ), strings_displayed=[ '<td>NM_005997_cds_0_0_chr1_147962193_r</td>' ] )
|
||||
self.logout()
|
||||
self.login( email=regular_user3.email )
|
||||
# Delete the clone so the next test will be valid
|
||||
@@ -628,13 +624,11 @@ class TestHistory( TwillTestCase ):
|
||||
# Unshare history5 from regular_user2
|
||||
self.unshare_history( self.security.encode_id( history5.id ),
|
||||
self.security.encode_id( regular_user2.id ),
|
||||
check_str1=regular_user1.email,
|
||||
check_str2=regular_user2.email )
|
||||
strings_displayed=[ regular_user1.email, regular_user2.email ] )
|
||||
# Unshare history5 from regular_user3
|
||||
self.unshare_history( self.security.encode_id( history5.id ),
|
||||
self.security.encode_id( regular_user3.id ),
|
||||
check_str1=regular_user1.email,
|
||||
check_str2=regular_user3.email )
|
||||
strings_displayed=[ regular_user1.email, regular_user3.email ] )
|
||||
# Make sure the history was unshared correctly
|
||||
self.logout()
|
||||
self.login( email=regular_user2.email )
|
||||
@@ -701,7 +695,7 @@ class TestHistory( TwillTestCase ):
|
||||
self.check_page_for_string( 'hg15' )
|
||||
self.assertEqual ( len( self.get_history_as_data_list() ), 1 )
|
||||
# Delete the history item
|
||||
self.delete_history_item( str( latest_hda.id ), check_str="Your history is empty" )
|
||||
self.delete_history_item( str( latest_hda.id ), strings_displayed=[ "Your history is empty" ] )
|
||||
self.assertEqual ( len( self.get_history_as_data_list() ), 0 )
|
||||
# Try deleting an invalid hid
|
||||
try:
|
||||
|
||||
@@ -32,193 +32,192 @@ class TestLibraryFeatures( TwillTestCase ):
|
||||
assert admin_user is not None, 'Problem retrieving user with email "test@bx.psu.edu" from the database'
|
||||
global admin_user_private_role
|
||||
admin_user_private_role = get_private_role( admin_user )
|
||||
def test_005_create_library( self ):
|
||||
"""Testing creating a new library, then renaming it"""
|
||||
def test_005_create_libraries( self ):
|
||||
"""Testing creating libraries used in this script, then renaming one of them"""
|
||||
# Logged in as admin_user
|
||||
name = "library features Library1"
|
||||
description = "library features Library1 description"
|
||||
synopsis = "library features Library1 synopsis"
|
||||
self.create_library( name=name, description=description, synopsis=synopsis )
|
||||
self.browse_libraries_admin( check_str1=name, check_str2=description )
|
||||
# Get the library object for later tests
|
||||
global library_one
|
||||
library_one = get_library( name, description, synopsis )
|
||||
assert library_one is not None, 'Problem retrieving library named "%s" from the database' % name
|
||||
for index in range( 0, 1 ):
|
||||
name = 'library%s' % str( index + 1 )
|
||||
description = '%s description' % name
|
||||
synopsis = '%s synopsis' % name
|
||||
self.create_library( name=name, description=description, synopsis=synopsis )
|
||||
self.browse_libraries_admin( strings_displayed=[ name, description ] )
|
||||
# Get the libraries for later use
|
||||
global library1
|
||||
library1 = get_library( 'library1', 'library1 description', 'library1 synopsis' )
|
||||
assert library1 is not None, 'Problem retrieving library (library1) from the database'
|
||||
# Rename the library
|
||||
new_name = "library features Library1 new name"
|
||||
new_description = "library features Library1 new description"
|
||||
new_synopsis = "library features Library1 new synopsis"
|
||||
new_name = "library1 new name"
|
||||
new_description = "library1 new description"
|
||||
new_synopsis = "library1 new synopsis"
|
||||
self.library_info( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
library_one.name,
|
||||
self.security.encode_id( library1.id ),
|
||||
library1.name,
|
||||
new_name=new_name,
|
||||
new_description=new_description,
|
||||
new_synopsis=new_synopsis )
|
||||
self.browse_libraries_admin( check_str1=new_name, check_str2=new_description )
|
||||
self.browse_libraries_admin( strings_displayed=[ new_name, new_description ] )
|
||||
# Reset the library back to the original name and description
|
||||
self.library_info( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
library_one.name,
|
||||
self.security.encode_id( library1.id ),
|
||||
library1.name,
|
||||
new_name=name,
|
||||
new_description=description,
|
||||
new_synopsis=synopsis )
|
||||
refresh( library_one )
|
||||
def test_030_add_new_folder_to_root_folder( self ):
|
||||
"""Testing adding a folder to a library root folder"""
|
||||
new_description='library1 description',
|
||||
new_synopsis='library1 synopsis' )
|
||||
refresh( library1 )
|
||||
def test_030_add_folder_to_library1( self ):
|
||||
"""Testing adding a folder to a library1"""
|
||||
# logged in as admin_user
|
||||
root_folder = library_one.root_folder
|
||||
name = "Root Folder's Folder One"
|
||||
description = "This is the root folder's Folder One"
|
||||
root_folder = library1.root_folder
|
||||
name = "folder1"
|
||||
description = "folder1 description"
|
||||
self.add_folder( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
self.security.encode_id( root_folder.id ),
|
||||
self.security.encode_id( library1.id ),
|
||||
self.security.encode_id( library1.root_folder.id ),
|
||||
name=name,
|
||||
description=description )
|
||||
global folder_one
|
||||
folder_one = get_folder( root_folder.id, name, description )
|
||||
assert folder_one is not None, 'Problem retrieving library folder named "%s" from the database' % name
|
||||
global folder1
|
||||
folder1 = get_folder( root_folder.id, name, description )
|
||||
assert folder1 is not None, 'Problem retrieving library folder named "%s" from the database' % name
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
check_str1=name,
|
||||
check_str2=description )
|
||||
self.security.encode_id( library1.id ),
|
||||
strings_displayed=[ folder1.name, folder1.description ] )
|
||||
def test_035_add_subfolder_to_folder( self ):
|
||||
"""Testing adding a folder to a library folder"""
|
||||
"""Testing adding a folder to a folder"""
|
||||
# logged in as admin_user
|
||||
name = "Folder One's Subfolder"
|
||||
description = "This is the Folder One's subfolder"
|
||||
self.add_folder( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
self.security.encode_id( folder_one.id ),
|
||||
self.security.encode_id( library1.id ),
|
||||
self.security.encode_id( folder1.id ),
|
||||
name=name,
|
||||
description=description )
|
||||
global subfolder_one
|
||||
subfolder_one = get_folder( folder_one.id, name, description )
|
||||
assert subfolder_one is not None, 'Problem retrieving library folder named "Folder Ones Subfolder" from the database'
|
||||
global subfolder1
|
||||
subfolder1 = get_folder( folder1.id, name, description )
|
||||
assert subfolder1 is not None, 'Problem retrieving subfolder1 from the database'
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
check_str1=name,
|
||||
check_str2=description )
|
||||
def test_040_add_2nd_new_folder_to_root_folder( self ):
|
||||
"""Testing adding a 2nd folder to a library root folder"""
|
||||
self.security.encode_id( library1.id ),
|
||||
strings_displayed=[ subfolder1.name, subfolder1.description ] )
|
||||
def test_040_add_2nd_folder_to_library1( self ):
|
||||
"""Testing adding a 2nd folder to a library1"""
|
||||
# logged in as admin_user
|
||||
root_folder = library_one.root_folder
|
||||
name = "Folder Two"
|
||||
description = "This is the root folder's Folder Two"
|
||||
name = "folder2"
|
||||
description = "folder2 description"
|
||||
self.add_folder( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
self.security.encode_id( root_folder.id ),
|
||||
self.security.encode_id( library1.id ),
|
||||
self.security.encode_id( library1.root_folder.id ),
|
||||
name=name,
|
||||
description=description )
|
||||
global folder_two
|
||||
folder_two = get_folder( root_folder.id, name, description )
|
||||
assert folder_two is not None, 'Problem retrieving library folder named "%s" from the database' % name
|
||||
global folder2
|
||||
folder2 = get_folder( library1.root_folder.id, name, description )
|
||||
assert folder2 is not None, 'Problem retrieving library folder named "%s" from the database' % name
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
check_str1=name,
|
||||
check_str2=description )
|
||||
def test_045_add_public_dataset_to_root_folders_2nd_subfolder( self ):
|
||||
"""Testing adding a public dataset to the root folder's 2nd sub-folder"""
|
||||
self.security.encode_id( library1.id ),
|
||||
strings_displayed=[ folder2.name, folder2.description ] )
|
||||
def test_045_add_public_dataset_to_folder2( self ):
|
||||
"""Testing adding a public dataset to folder2"""
|
||||
# Logged in as admin_user
|
||||
message = "Testing adding a public dataset to the folder named %s" % folder_two.name
|
||||
self.add_library_dataset( 'library_admin',
|
||||
'2.bed',
|
||||
self.security.encode_id( library_one.id ),
|
||||
self.security.encode_id( folder_two.id ),
|
||||
folder_two.name,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
message=message.replace( ' ', '+' ),
|
||||
root=False )
|
||||
global ldda_two
|
||||
ldda_two = get_latest_ldda()
|
||||
assert ldda_two is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda_two from the database'
|
||||
filename = '2.bed'
|
||||
ldda_message = "Testing uploading %s" % filename
|
||||
self.upload_library_dataset( cntrller='library_admin',
|
||||
library_id=self.security.encode_id( library1.id ),
|
||||
folder_id=self.security.encode_id( folder2.id ),
|
||||
filename=filename,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
ldda_message=ldda_message,
|
||||
strings_displayed=[ 'Upload files' ] )
|
||||
global ldda2
|
||||
ldda2 = get_latest_ldda()
|
||||
assert ldda2 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda2 from the database'
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
check_str1='2.bed',
|
||||
check_str2=message,
|
||||
check_str3=admin_user.email )
|
||||
def test_050_add_2nd_public_dataset_to_root_folders_2nd_subfolder( self ):
|
||||
"""Testing adding a 2nd public dataset to the root folder's 2nd sub-folder"""
|
||||
self.security.encode_id( library1.id ),
|
||||
strings_displayed=[ ldda2.name, ldda2.message, admin_user.email ] )
|
||||
def test_050_add_2nd_public_dataset_to_folder2( self ):
|
||||
"""Testing adding a 2nd public dataset folder2"""
|
||||
# Logged in as admin_user
|
||||
message = "Testing adding a 2nd public dataset to the folder named %s" % folder_two.name
|
||||
self.add_library_dataset( 'library_admin',
|
||||
'3.bed',
|
||||
self.security.encode_id( library_one.id ),
|
||||
self.security.encode_id( folder_two.id ),
|
||||
folder_two.name,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
message=message.replace( ' ', '+' ),
|
||||
root=False )
|
||||
global ldda_three
|
||||
ldda_three = get_latest_ldda()
|
||||
assert ldda_three is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda_three from the database'
|
||||
filename='3.bed'
|
||||
ldda_message = "Testing uploading %s" % filename
|
||||
self.upload_library_dataset( cntrller='library_admin',
|
||||
library_id=self.security.encode_id( library1.id ),
|
||||
folder_id=self.security.encode_id( folder2.id ),
|
||||
filename=filename,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
ldda_message=ldda_message,
|
||||
strings_displayed=[ 'Upload files' ] )
|
||||
global ldda3
|
||||
ldda3 = get_latest_ldda()
|
||||
assert ldda3 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda3 from the database'
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
check_str1='3.bed',
|
||||
check_str2=message,
|
||||
check_str3=admin_user.email )
|
||||
self.security.encode_id( library1.id ),
|
||||
strings_displayed=[ ldda3.name, ldda3.message, admin_user.email ] )
|
||||
def test_055_copy_dataset_from_history_to_subfolder( self ):
|
||||
"""Testing copying a dataset from the current history to a subfolder"""
|
||||
# logged in as admin_user
|
||||
self.new_history()
|
||||
self.upload_file( "4.bed" )
|
||||
latest_hda = get_latest_hda()
|
||||
self.add_history_datasets_to_library( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
self.security.encode_id( subfolder_one.id ),
|
||||
subfolder_one.name,
|
||||
self.security.encode_id( latest_hda.id ),
|
||||
root=False )
|
||||
global ldda_four
|
||||
ldda_four = get_latest_ldda()
|
||||
assert ldda_four is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda_four from the database'
|
||||
self.upload_library_dataset( cntrller='library_admin',
|
||||
library_id=self.security.encode_id( library1.id ),
|
||||
folder_id=self.security.encode_id( subfolder1.id ),
|
||||
upload_option='import_from_history',
|
||||
hda_ids=self.security.encode_id( latest_hda.id ),
|
||||
ldda_message='Imported from history',
|
||||
strings_displayed=[ 'Active datasets in your current history' ] )
|
||||
global ldda4
|
||||
ldda4 = get_latest_ldda()
|
||||
assert ldda4 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda4 from the database'
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library1.id ),
|
||||
strings_displayed=[ ldda4.name, ldda4.message, admin_user.email ] )
|
||||
def test_060_editing_dataset_attribute_info( self ):
|
||||
"""Testing editing a library dataset's attribute information"""
|
||||
# logged in as admin_user
|
||||
new_ldda_name = '4.bed ( version 1 )'
|
||||
self.ldda_edit_info( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
self.security.encode_id( subfolder_one.id ),
|
||||
self.security.encode_id( ldda_four.id ),
|
||||
ldda_four.name,
|
||||
self.security.encode_id( library1.id ),
|
||||
self.security.encode_id( subfolder1.id ),
|
||||
self.security.encode_id( ldda4.id ),
|
||||
ldda4.name,
|
||||
new_ldda_name=new_ldda_name )
|
||||
refresh( ldda_four )
|
||||
self.browse_library( 'library_admin', self.security.encode_id( library_one.id ), check_str1=new_ldda_name )
|
||||
refresh( ldda4 )
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library1.id ),
|
||||
strings_displayed=[ new_ldda_name, ldda4.message ] )
|
||||
def test_065_uploading_new_dataset_version( self ):
|
||||
"""Testing uploading a new version of a library dataset"""
|
||||
# logged in as admin_user
|
||||
message = 'Testing uploading a new version of a dataset'
|
||||
self.upload_new_dataset_version( 'library_admin',
|
||||
'4.bed',
|
||||
self.security.encode_id( library_one.id ),
|
||||
self.security.encode_id( subfolder_one.id ),
|
||||
subfolder_one.name,
|
||||
self.security.encode_id( ldda_four.library_dataset.id ),
|
||||
ldda_four.name,
|
||||
file_type='auto',
|
||||
dbkey='hg18',
|
||||
message=message.replace( ' ', '+' ) )
|
||||
global ldda_four_version_two
|
||||
ldda_four_version_two = get_latest_ldda()
|
||||
assert ldda_four_version_two is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda_four_version_two from the database'
|
||||
filename = '4.bed'
|
||||
ldda_message = 'Testing uploading a new version of a dataset'
|
||||
self.upload_library_dataset( cntrller='library_admin',
|
||||
library_id=self.security.encode_id( library1.id ),
|
||||
folder_id=self.security.encode_id( subfolder1.id ),
|
||||
replace_id=self.security.encode_id( ldda4.library_dataset.id ),
|
||||
filename=filename,
|
||||
file_type='auto',
|
||||
dbkey='hg18',
|
||||
ldda_message=ldda_message,
|
||||
strings_displayed=[ 'Upload files', 'You are currently selecting a new file to replace' ] )
|
||||
global ldda4_version2
|
||||
ldda4_version2 = get_latest_ldda()
|
||||
assert ldda4_version2 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda4_version2 from the database'
|
||||
self.ldda_edit_info( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
self.security.encode_id( subfolder_one.id ),
|
||||
self.security.encode_id( ldda_four_version_two.id ),
|
||||
ldda_four_version_two.name,
|
||||
check_str1='This is the latest version of this library dataset' )
|
||||
self.security.encode_id( library1.id ),
|
||||
self.security.encode_id( subfolder1.id ),
|
||||
self.security.encode_id( ldda4_version2.id ),
|
||||
ldda4_version2.name,
|
||||
strings_displayed=[ 'This is the latest version of this library dataset' ] )
|
||||
# Check the previous version
|
||||
self.ldda_edit_info( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
self.security.encode_id( subfolder_one.id ),
|
||||
self.security.encode_id( ldda_four.id ),
|
||||
ldda_four.name,
|
||||
check_str1='This is an expired version of this library dataset' )
|
||||
# Make sure ldda_four is no longer displayed in the library
|
||||
self.security.encode_id( library1.id ),
|
||||
self.security.encode_id( subfolder1.id ),
|
||||
self.security.encode_id( ldda4.id ),
|
||||
ldda4.name,
|
||||
strings_displayed=[ 'This is an expired version of this library dataset' ] )
|
||||
# Make sure ldda4 is no longer displayed in the library
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
not_displayed=ldda_four.name )
|
||||
self.security.encode_id( library1.id ),
|
||||
strings_not_displayed=[ ldda4.name, ldda4.message ] )
|
||||
def test_070_upload_directory_of_files_from_libraries_view( self ):
|
||||
"""Testing uploading a directory of files to a root folder from the Data Libraries view"""
|
||||
# logged in as admin_user
|
||||
@@ -226,162 +225,157 @@ class TestLibraryFeatures( TwillTestCase ):
|
||||
# Libraries view since a sub-directory named the same as their email is not contained
|
||||
# in the configured user_library_import_dir ( in the test_data directory, only regular_user1
|
||||
# and regular_user3 have directories ). We'll need to give these 2 user LIBRARY_ADD permission
|
||||
# on library_one to test this feature.
|
||||
# on library1 to test this feature.
|
||||
permissions_in = [ 'LIBRARY_ADD' ]
|
||||
permissions_out = [ 'LIBRARY_ACCESS', 'LIBRARY_MODIFY', 'LIBRARY_MANAGE' ]
|
||||
role_ids = '%s,%s' % ( str( regular_user1_private_role.id ), str( regular_user3_private_role.id ) )
|
||||
# Role one members are: admin_user, regular_user1, regular_user3. Each of these users will be permitted for
|
||||
# LIBRARY_ACCESS, LIBRARY_ADD, LIBRARY_MODIFY, LIBRARY_MANAGE on this library and it's contents.
|
||||
self.library_permissions( self.security.encode_id( library_one.id ),
|
||||
library_one.name,
|
||||
self.library_permissions( self.security.encode_id( library1.id ),
|
||||
library1.name,
|
||||
role_ids,
|
||||
permissions_in,
|
||||
permissions_out )
|
||||
self.logout()
|
||||
# Now that we have permissions set on the library, we can proceed to test uploading files
|
||||
self.login( email=regular_user1.email )
|
||||
message = 'Uploaded all files in test-data/users/test1...'
|
||||
ldda_message = 'Uploaded all files in test-data/users/test1...'
|
||||
# Since regular_user1 does not have any sub-directories contained within her configured
|
||||
# user_library_import_dir, the only option in her server_dir select list will be the
|
||||
# directory named the same as her email
|
||||
check_str_after_submit = "Added 1 datasets to the library '%s' (each is selected)." % library_one.root_folder.name
|
||||
self.upload_directory_of_files( 'library',
|
||||
self.security.encode_id( library_one.id ),
|
||||
self.security.encode_id( library_one.root_folder.id ),
|
||||
server_dir=regular_user1.email,
|
||||
message=message,
|
||||
check_str_after_submit=check_str_after_submit )
|
||||
self.upload_library_dataset( cntrller='library',
|
||||
library_id=self.security.encode_id( library1.id ),
|
||||
folder_id=self.security.encode_id( library1.root_folder.id ),
|
||||
upload_option='upload_directory',
|
||||
server_dir=regular_user1.email,
|
||||
ldda_message=ldda_message,
|
||||
strings_displayed = [ "Upload a directory of files" ] )
|
||||
self.browse_library( 'library',
|
||||
self.security.encode_id( library_one.id ),
|
||||
check_str1=regular_user1.email,
|
||||
check_str2=message )
|
||||
self.security.encode_id( library1.id ),
|
||||
strings_displayed=[ regular_user1.email, ldda_message, '1.fasta' ] )
|
||||
self.logout()
|
||||
self.login( regular_user3.email )
|
||||
message = 'Uploaded all files in test-data/users/test3.../run1'
|
||||
ldda_message = 'Uploaded all files in test-data/users/test3.../run1'
|
||||
# Since regular_user2 has a subdirectory contained within her configured user_library_import_dir,
|
||||
# she will have a "None" option in her server_dir select list
|
||||
self.upload_directory_of_files( 'library',
|
||||
self.security.encode_id( library_one.id ),
|
||||
self.security.encode_id( library_one.root_folder.id ),
|
||||
server_dir='run1',
|
||||
message=message,
|
||||
check_str1='<option>None</option>',
|
||||
check_str_after_submit=check_str_after_submit )
|
||||
self.upload_library_dataset( cntrller='library',
|
||||
library_id=self.security.encode_id( library1.id ),
|
||||
folder_id=self.security.encode_id( library1.root_folder.id ),
|
||||
upload_option='upload_directory',
|
||||
server_dir='run1',
|
||||
ldda_message=ldda_message,
|
||||
strings_displayed=[ 'Upload a directory of files', '<option>None</option>' ] )
|
||||
self.browse_library( 'library',
|
||||
self.security.encode_id( library_one.id ),
|
||||
check_str1=regular_user3.email,
|
||||
check_str2=message )
|
||||
self.security.encode_id( library1.id ),
|
||||
strings_displayed=[ regular_user3.email, ldda_message, '2.fasta' ] )
|
||||
def test_075_download_archive_of_library_files( self ):
|
||||
"""Testing downloading an archive of files from the library"""
|
||||
"""Testing downloading an archive of files from library1"""
|
||||
# logged in as regular_user3
|
||||
self.logout()
|
||||
self.login( email=admin_user.email )
|
||||
self.add_library_dataset( 'library_admin',
|
||||
'1.bed',
|
||||
self.security.encode_id( library_one.id ),
|
||||
self.security.encode_id( library_one.root_folder.id ),
|
||||
library_one.root_folder.name,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
root=True )
|
||||
global ldda_one
|
||||
ldda_one = get_latest_ldda()
|
||||
assert ldda_one is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda_one from the database'
|
||||
self.upload_library_dataset( cntrller='library_admin',
|
||||
library_id=self.security.encode_id( library1.id ),
|
||||
folder_id=self.security.encode_id( library1.root_folder.id ),
|
||||
filename='1.bed',
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
strings_displayed=[ 'Upload files' ] )
|
||||
global ldda1
|
||||
ldda1 = get_latest_ldda()
|
||||
assert ldda1 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda1 from the database'
|
||||
for format in ( 'tbz', 'tgz', 'zip' ):
|
||||
archive = self.download_archive_of_library_files( cntrller='library',
|
||||
library_id=self.security.encode_id( library_one.id ),
|
||||
ldda_ids=[ self.security.encode_id( ldda_one.id ), self.security.encode_id( ldda_two.id ) ],
|
||||
library_id=self.security.encode_id( library1.id ),
|
||||
ldda_ids=[ self.security.encode_id( ldda1.id ), self.security.encode_id( ldda2.id ) ],
|
||||
format=format )
|
||||
self.check_archive_contents( archive, ( ldda_one, ldda_two ) )
|
||||
self.check_archive_contents( archive, ( ldda1, ldda2 ) )
|
||||
os.remove( archive )
|
||||
def test_080_mark_dataset_deleted( self ):
|
||||
"""Testing marking a library dataset as deleted"""
|
||||
def test_080_mark_ldda2_deleted( self ):
|
||||
"""Testing marking ldda2 as deleted"""
|
||||
# Logged in as admin_user
|
||||
self.delete_library_item( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
self.security.encode_id( ldda_two.library_dataset.id ),
|
||||
ldda_two.name,
|
||||
self.security.encode_id( library1.id ),
|
||||
self.security.encode_id( ldda2.library_dataset.id ),
|
||||
ldda2.name,
|
||||
item_type='library_dataset' )
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
not_displayed=ldda_two.name )
|
||||
def test_085_display_and_hide_deleted_dataset( self ):
|
||||
"""Testing displaying and hiding a deleted library dataset"""
|
||||
self.security.encode_id( library1.id ),
|
||||
strings_not_displayed=[ ldda2.name, ldda2.message ] )
|
||||
def test_085_display_and_hide_deleted_ldda2( self ):
|
||||
"""Testing displaying and hiding a deleted ldda2"""
|
||||
# Logged in as admin_user
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
self.security.encode_id( library1.id ),
|
||||
show_deleted=True,
|
||||
check_str1=ldda_two.name )
|
||||
strings_displayed=[ ldda2.name, ldda2.message ] )
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
not_displayed=ldda_two.name )
|
||||
def test_090_mark_folder_deleted( self ):
|
||||
"""Testing marking a library folder as deleted"""
|
||||
self.security.encode_id( library1.id ),
|
||||
strings_not_displayed=[ ldda2.name, ldda2.message ] )
|
||||
def test_090_mark_folder2_deleted( self ):
|
||||
"""Testing marking folder2 as deleted"""
|
||||
# Logged in as admin_user
|
||||
self.delete_library_item( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
self.security.encode_id( folder_two.id ),
|
||||
folder_two.name,
|
||||
self.security.encode_id( library1.id ),
|
||||
self.security.encode_id( folder2.id ),
|
||||
folder2.name,
|
||||
item_type='folder' )
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
not_displayed=folder_two.name )
|
||||
self.security.encode_id( library1.id ),
|
||||
strings_not_displayed=[ folder2.name ] )
|
||||
def test_095_mark_folder_undeleted( self ):
|
||||
"""Testing marking a library folder as undeleted"""
|
||||
# Logged in as admin_user
|
||||
self.undelete_library_item( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
self.security.encode_id( folder_two.id ),
|
||||
folder_two.name,
|
||||
self.security.encode_id( library1.id ),
|
||||
self.security.encode_id( folder2.id ),
|
||||
folder2.name,
|
||||
item_type='folder' )
|
||||
# 2.bed was deleted before the folder was deleted, so state should have been saved. In order
|
||||
# for 2.bed to be displayed, it would itself have to be marked undeleted.
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
check_str1=folder_two.name,
|
||||
not_displayed=ldda_two.name )
|
||||
self.security.encode_id( library1.id ),
|
||||
strings_displayed=[ folder2.name ],
|
||||
strings_not_displayed=[ ldda2.name ] )
|
||||
def test_100_mark_library_deleted( self ):
|
||||
"""Testing marking a library as deleted"""
|
||||
# Logged in as admin_user
|
||||
# First mark folder_two as deleted to further test state saving when we undelete the library
|
||||
# First mark folder2 as deleted to further test state saving when we undelete the library
|
||||
self.delete_library_item( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
self.security.encode_id( folder_two.id ),
|
||||
folder_two.name,
|
||||
self.security.encode_id( library1.id ),
|
||||
self.security.encode_id( folder2.id ),
|
||||
folder2.name,
|
||||
item_type='folder' )
|
||||
self.delete_library_item( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
self.security.encode_id( library_one.id ),
|
||||
library_one.name,
|
||||
self.security.encode_id( library1.id ),
|
||||
self.security.encode_id( library1.id ),
|
||||
library1.name,
|
||||
item_type='library' )
|
||||
self.browse_libraries_admin( not_displayed1=library_one.name )
|
||||
self.browse_libraries_admin( deleted=True, check_str1=library_one.name )
|
||||
self.browse_libraries_admin( strings_not_displayed=[ library1.name ] )
|
||||
self.browse_libraries_admin( deleted=True, strings_displayed=[ library1.name ] )
|
||||
def test_105_mark_library_undeleted( self ):
|
||||
"""Testing marking a library as undeleted"""
|
||||
# Logged in as admin_user
|
||||
self.undelete_library_item( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
self.security.encode_id( library_one.id ),
|
||||
library_one.name,
|
||||
self.security.encode_id( library1.id ),
|
||||
self.security.encode_id( library1.id ),
|
||||
library1.name,
|
||||
item_type='library' )
|
||||
self.browse_libraries_admin( check_str1=library_one.name )
|
||||
self.browse_libraries_admin( strings_displayed=[ library1.name ] )
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
check_str1=library_one.name,
|
||||
not_displayed=folder_two.name )
|
||||
self.security.encode_id( library1.id ),
|
||||
strings_displayed=[ library1.name ],
|
||||
strings_not_displayed=[ folder2.name ] )
|
||||
def test_110_purge_library( self ):
|
||||
"""Testing purging a library"""
|
||||
# Logged in as admin_user
|
||||
self.delete_library_item( 'library_admin',
|
||||
self.security.encode_id( library_one.id ),
|
||||
self.security.encode_id( library_one.id ),
|
||||
library_one.name,
|
||||
self.security.encode_id( library1.id ),
|
||||
self.security.encode_id( library1.id ),
|
||||
library1.name,
|
||||
item_type='library' )
|
||||
self.purge_library( self.security.encode_id( library_one.id ), library_one.name )
|
||||
self.purge_library( self.security.encode_id( library1.id ), library1.name )
|
||||
# Make sure the library was purged
|
||||
refresh( library_one )
|
||||
if not ( library_one.deleted and library_one.purged ):
|
||||
raise AssertionError( 'The library id %s named "%s" has not been marked as deleted and purged.' % ( str( library_one.id ), library_one.name ) )
|
||||
refresh( library1 )
|
||||
if not ( library1.deleted and library1.purged ):
|
||||
raise AssertionError( 'The library id %s named "%s" has not been marked as deleted and purged.' % ( str( library1.id ), library1.name ) )
|
||||
def check_folder( library_folder ):
|
||||
for folder in library_folder.folders:
|
||||
refresh( folder )
|
||||
@@ -408,52 +402,14 @@ class TestLibraryFeatures( TwillTestCase ):
|
||||
if not library_dataset.deleted:
|
||||
raise AssertionError( 'The library_dataset id %s named "%s" has not been marked as deleted.' % \
|
||||
( str( library_dataset.id ), library_dataset.name ) )
|
||||
check_folder( library_one.root_folder )
|
||||
def test_115_no_library_template( self ):
|
||||
"""Test library features when library has no template"""
|
||||
# Logged in as admin_user
|
||||
name = "library features Library Two"
|
||||
description = "library features This is Library Two"
|
||||
synopsis = "library features Library Two synopsis"
|
||||
# Create a library, adding no template
|
||||
self.create_library( name=name, description=description, synopsis=synopsis )
|
||||
self.browse_libraries_admin( check_str1=name, check_str2=description )
|
||||
global library_two
|
||||
library_two = get_library( name, description, synopsis )
|
||||
assert library_two is not None, 'Problem retrieving library named "%s" from the database' % name
|
||||
# Add a dataset to the library
|
||||
self.add_library_dataset( 'library_admin',
|
||||
'3.bed',
|
||||
self.security.encode_id( library_two.id ),
|
||||
self.security.encode_id( library_two.root_folder.id ),
|
||||
library_two.root_folder.name,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
message='',
|
||||
root=True )
|
||||
ldda_three = get_latest_ldda()
|
||||
assert ldda_three is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda_three from the database'
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library_two.id ),
|
||||
check_str1='3.bed',
|
||||
check_str2=admin_user.email )
|
||||
# TODO: add a functional test to cover adding a library dataset via url_paste here...
|
||||
# TODO: Add a functional test to cover checking the space_to_tab checkbox here...
|
||||
# Delete and purge the library
|
||||
self.delete_library_item( 'library_admin',
|
||||
self.security.encode_id( library_two.id ),
|
||||
self.security.encode_id( library_two.id ),
|
||||
library_two.name,
|
||||
item_type='library' )
|
||||
self.purge_library( self.security.encode_id( library_two.id ), library_two.name )
|
||||
self.home()
|
||||
check_folder( library1.root_folder )
|
||||
def test_999_reset_data_for_later_test_runs( self ):
|
||||
"""Reseting data to enable later test runs to pass"""
|
||||
# Logged in as admin_user
|
||||
##################
|
||||
# Purge all libraries
|
||||
##################
|
||||
for library in [ library_one, library_two ]:
|
||||
for library in [ library1 ]:
|
||||
self.delete_library_item( 'library_admin',
|
||||
self.security.encode_id( library.id ),
|
||||
self.security.encode_id( library.id ),
|
||||
|
||||
@@ -141,25 +141,23 @@ class TestLibrarySecurity( TwillTestCase ):
|
||||
# LIBRARY_MANAGE = "Role1" via inheritance from parent folder
|
||||
#
|
||||
# This means that only regular_user1 can see the dataset from the Data Libraries view
|
||||
message ='ldda1'
|
||||
self.add_library_dataset( 'library_admin',
|
||||
'1.bed',
|
||||
self.security.encode_id( library1.id ),
|
||||
self.security.encode_id( folder1.id ),
|
||||
folder1.name,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
roles=[ str( regular_user1_private_role.id ) ],
|
||||
message=message,
|
||||
root=False )
|
||||
filename = '1.bed'
|
||||
ldda_message ='ldda1'
|
||||
self.upload_library_dataset( cntrller='library_admin',
|
||||
library_id=self.security.encode_id( library1.id ),
|
||||
folder_id=self.security.encode_id( folder1.id ),
|
||||
filename=filename,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
roles=[ str( regular_user1_private_role.id ) ],
|
||||
ldda_message=ldda_message,
|
||||
strings_displayed=[ 'Upload files' ] )
|
||||
global ldda1
|
||||
ldda1 = get_latest_ldda()
|
||||
assert ldda1 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda1 from the database'
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library1.id ),
|
||||
check_str1='1.bed',
|
||||
check_str2=message,
|
||||
check_str3=admin_user.email )
|
||||
strings_displayed=[ ldda1.name, ldda1.message, admin_user.email ] )
|
||||
def test_030_access_ldda1_with_private_role_restriction( self ):
|
||||
"""Testing accessing ldda1 with a private role restriction"""
|
||||
# Logged in as admin_user
|
||||
@@ -178,28 +176,25 @@ class TestLibrarySecurity( TwillTestCase ):
|
||||
# admin_user should not be able to see 1.bed from the analysis view's access libraries
|
||||
self.browse_library( 'library',
|
||||
self.security.encode_id( library1.id ),
|
||||
not_displayed=folder1.name,
|
||||
not_displayed2='1.bed' )
|
||||
strings_not_displayed=[ folder1.name, ldda1.name, ldda1.message ] )
|
||||
self.logout()
|
||||
# regular_user1 should be able to see 1.bed from the Data Libraries view
|
||||
# since it was associated with regular_user1's private role
|
||||
self.login( email=regular_user1.email )
|
||||
self.browse_library( 'library',
|
||||
self.security.encode_id( library1.id ),
|
||||
check_str1=folder1.name,
|
||||
check_str2='1.bed' )
|
||||
strings_displayed=[ folder1.name, ldda1.name, ldda1.message ] )
|
||||
self.logout()
|
||||
# regular_user2 should not be to see library1 since they do not have
|
||||
# Role1 which is associated with the LIBRARY_ACCESS permission
|
||||
self.login( email=regular_user2.email )
|
||||
self.browse_libraries_regular_user( not_displayed1=library1.name )
|
||||
self.browse_libraries_regular_user( strings_not_displayed=[ library1.name ] )
|
||||
self.logout()
|
||||
# regular_user3 should not be able to see 1.bed from the analysis view's access librarys
|
||||
self.login( email=regular_user3.email )
|
||||
self.browse_library( 'library',
|
||||
self.security.encode_id( library1.id ),
|
||||
not_displayed=folder1.name,
|
||||
not_displayed2='1.bed' )
|
||||
strings_not_displayed=[ folder1.name ] )
|
||||
self.logout()
|
||||
self.login( email=admin_user.email )
|
||||
def test_035_change_ldda1_access_permission( self ):
|
||||
@@ -223,7 +218,7 @@ class TestLibrarySecurity( TwillTestCase ):
|
||||
role_ids_str,
|
||||
permissions_in,
|
||||
permissions_out,
|
||||
check_str1=check_str )
|
||||
strings_displayed=[ check_str ] )
|
||||
role_ids_str = str( role1.id )
|
||||
self.ldda_permissions( 'library_admin',
|
||||
self.security.encode_id( library1.id ),
|
||||
@@ -236,7 +231,7 @@ class TestLibrarySecurity( TwillTestCase ):
|
||||
# admin_user should now be able to see 1.bed from the analysis view's access libraries
|
||||
self.browse_library( 'library',
|
||||
self.security.encode_id( library1.id ),
|
||||
check_str1=ldda1.name )
|
||||
strings_displayed=[ ldda1.name, ldda1.message ] )
|
||||
def test_040_create_ldda2_with_role2_associated_with_group_and_users( self ):
|
||||
"""Testing creating ldda2 with a role that is associated with a group and users"""
|
||||
# Logged in as admin_user
|
||||
@@ -251,41 +246,36 @@ class TestLibrarySecurity( TwillTestCase ):
|
||||
contents=False,
|
||||
library_name=library1.name )
|
||||
refresh( library1 )
|
||||
message = 'ldda2: a dataset with role2 that is associated with a group and users'
|
||||
self.add_library_dataset( 'library_admin',
|
||||
'2.bed',
|
||||
self.security.encode_id( library1.id ),
|
||||
self.security.encode_id( folder1.id ),
|
||||
folder1.name,
|
||||
file_type='bed',
|
||||
dbkey='hg17',
|
||||
roles=[ str( role2.id ) ],
|
||||
message=message.replace( ' ', '+' ),
|
||||
root=False )
|
||||
filename = '2.bed'
|
||||
ldda_message = 'ldda2'
|
||||
self.upload_library_dataset( cntrller='library_admin',
|
||||
library_id=self.security.encode_id( library1.id ),
|
||||
folder_id=self.security.encode_id( folder1.id ),
|
||||
filename=filename,
|
||||
file_type='bed',
|
||||
dbkey='hg17',
|
||||
roles=[ str( role2.id ) ],
|
||||
ldda_message=ldda_message,
|
||||
strings_displayed=[ 'Upload files' ] )
|
||||
global ldda2
|
||||
ldda2 = get_latest_ldda()
|
||||
assert ldda2 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda2 from the database'
|
||||
self.browse_library( 'library',
|
||||
self.security.encode_id( library1.id ),
|
||||
check_str1='2.bed',
|
||||
check_str2=message,
|
||||
check_str3=admin_user.email )
|
||||
strings_displayed=[ ldda2.name, ldda2.message, admin_user.email ] )
|
||||
def test_045_accessing_ldda2_with_role_associated_with_group_and_users( self ):
|
||||
"""Testing accessing ldda2 with a role that is associated with a group and users"""
|
||||
# Logged in as admin_user
|
||||
# admin_user should be able to see 2.bed since she is associated with role2
|
||||
self.browse_library( 'library',
|
||||
self.security.encode_id( library1.id ),
|
||||
check_str1='2.bed',
|
||||
check_str2=admin_user.email )
|
||||
strings_displayed=[ ldda2.name, ldda2.message, admin_user.email ] )
|
||||
self.logout()
|
||||
# regular_user1 should be able to see 2.bed since she is associated with group_two
|
||||
self.login( email = 'test1@bx.psu.edu' )
|
||||
self.browse_library( 'library',
|
||||
self.security.encode_id( library1.id ),
|
||||
check_str1=folder1.name,
|
||||
check_str2='2.bed',
|
||||
check_str3=admin_user.email )
|
||||
strings_displayed=[ folder1.name, ldda2.name, ldda2.message, admin_user.email ] )
|
||||
# Check the permissions on the dataset 2.bed - they are as folows:
|
||||
# DATASET_MANAGE_PERMISSIONS = test@bx.psu.edu
|
||||
# DATASET_ACCESS = Role2
|
||||
@@ -303,29 +293,28 @@ class TestLibrarySecurity( TwillTestCase ):
|
||||
self.security.encode_id( folder1.id ),
|
||||
self.security.encode_id( ldda2.id ),
|
||||
ldda2.name,
|
||||
check_str1='2.bed',
|
||||
check_str2='This is the latest version of this library dataset',
|
||||
check_str3='Edit attributes of 2.bed' )
|
||||
strings_displayed=['2.bed',
|
||||
'This is the latest version of this library dataset',
|
||||
'Edit attributes of 2.bed' ] )
|
||||
self.act_on_multiple_datasets( 'library',
|
||||
self.security.encode_id( library1.id ),
|
||||
'import_to_history',
|
||||
ldda_ids=self.security.encode_id( ldda2.id ),
|
||||
check_str1='1 dataset(s) have been imported into your history' )
|
||||
strings_displayed=[ '1 dataset(s) have been imported into your history' ] )
|
||||
self.logout()
|
||||
# regular_user2 should not be able to see ldda2
|
||||
self.login( email=regular_user2.email )
|
||||
self.browse_library( 'library',
|
||||
self.security.encode_id( library1.id ),
|
||||
not_displayed=folder1.name,
|
||||
not_displayed2=ldda2.name )
|
||||
strings_not_displayed=[ folder1.name, ldda2.name, ldda2.message ] )
|
||||
|
||||
self.logout()
|
||||
# regular_user3 should not be able to see ldda2
|
||||
self.login( email=regular_user3.email )
|
||||
self.browse_library( 'library',
|
||||
self.security.encode_id( library1.id ),
|
||||
check_str1=folder1.name,
|
||||
not_displayed=ldda2.name )
|
||||
strings_displayed=[ folder1.name ],
|
||||
strings_not_displayed=[ ldda2.name, ldda2.message ] )
|
||||
self.logout()
|
||||
self.login( email=admin_user.email )
|
||||
# Now makse ldda2 publicly accessible
|
||||
@@ -338,8 +327,7 @@ class TestLibrarySecurity( TwillTestCase ):
|
||||
self.login( email=regular_user2.email )
|
||||
self.browse_library( 'library',
|
||||
self.security.encode_id( library1.id ),
|
||||
check_str1=folder1.name,
|
||||
check_str2=ldda2.name )
|
||||
strings_displayed=[ folder1.name, ldda2.name, ldda2.message ] )
|
||||
self.logout()
|
||||
self.login( email=admin_user.email )
|
||||
# Now make folder1 publicly acessible
|
||||
@@ -352,25 +340,23 @@ class TestLibrarySecurity( TwillTestCase ):
|
||||
self.login( email=regular_user3.email )
|
||||
self.browse_library( 'library',
|
||||
self.security.encode_id( library1.id ),
|
||||
check_str1=folder1.name,
|
||||
check_str2=ldda1.name )
|
||||
strings_displayed=[ folder1.name, ldda1.name, ldda1.message ] )
|
||||
self.logout()
|
||||
self.login( email=admin_user.email )
|
||||
def test_050_upload_directory_of_files_from_admin_view( self ):
|
||||
"""Testing uploading a directory of files to library1 from the Admin view"""
|
||||
# logged in as admin_user
|
||||
message = 'This is a test for uploading a directory of files'
|
||||
check_str_after_submit="Added 3 datasets to the library '%s' (each is selected)." % library1.root_folder.name
|
||||
self.upload_directory_of_files( 'library_admin',
|
||||
self.security.encode_id( library1.id ),
|
||||
self.security.encode_id( library1.root_folder.id ),
|
||||
server_dir='library',
|
||||
message=message,
|
||||
check_str_after_submit=check_str_after_submit )
|
||||
ldda_message = 'This is a test for uploading a directory of files'
|
||||
self.upload_library_dataset( cntrller='library_admin',
|
||||
library_id=self.security.encode_id( library1.id ),
|
||||
folder_id=self.security.encode_id( library1.root_folder.id ),
|
||||
upload_option='upload_directory',
|
||||
server_dir='library',
|
||||
ldda_message=ldda_message,
|
||||
strings_displayed=[ "Upload a directory of files" ] )
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library1.id ),
|
||||
check_str1=admin_user.email,
|
||||
check_str2=message )
|
||||
strings_displayed=[ admin_user.email, ldda_message ] )
|
||||
def test_055_change_permissions_on_datasets_uploaded_from_library_dir( self ):
|
||||
"""Testing changing the permissions on datasets uploaded from a directory from the Admin view"""
|
||||
# logged in as admin_user
|
||||
@@ -390,11 +376,10 @@ class TestLibrarySecurity( TwillTestCase ):
|
||||
ldda_ids,
|
||||
str( role1.id ),
|
||||
permissions_in=[ 'DATASET_ACCESS', 'LIBRARY_MANAGE' ],
|
||||
check_str1='Permissions updated for 3 datasets.' )
|
||||
strings_displayed=[ 'Permissions updated for 3 datasets.' ] )
|
||||
# Make sure the permissions have been correctly updated for the 3 datasets. Permissions should
|
||||
# be all of the above on any of the 3 datasets that are imported into a history.
|
||||
def check_edit_page( lddas, check_str1='', check_str2='', check_str3='', check_str4='',
|
||||
not_displayed1='', not_displayed2='', not_displayed3='' ):
|
||||
def check_edit_page( lddas, strings_displayed=[], strings_not_displayed=[] ):
|
||||
for ldda in lddas:
|
||||
# Import each library dataset into our history
|
||||
self.act_on_multiple_datasets( 'library',
|
||||
@@ -404,15 +389,12 @@ class TestLibrarySecurity( TwillTestCase ):
|
||||
# Determine the new HistoryDatasetAssociation id created when the library dataset was imported into our history
|
||||
last_hda_created = get_latest_hda()
|
||||
self.edit_hda_attribute_info( str( last_hda_created.id ),
|
||||
check_str1=check_str1,
|
||||
check_str2=check_str2,
|
||||
check_str3=check_str3,
|
||||
check_str4=check_str4 )
|
||||
strings_displayed=strings_displayed )
|
||||
# admin_user is associated with role1, so should have all permissions on imported datasets
|
||||
check_edit_page( latest_3_lddas,
|
||||
check_str1='Manage dataset permissions on',
|
||||
check_str2='Role members can manage the roles associated with permissions on this dataset',
|
||||
check_str3='Role members can import this dataset into their history for analysis' )
|
||||
strings_displayed=[ 'Manage dataset permissions on',
|
||||
'Role members can manage the roles associated with permissions on this dataset',
|
||||
'Role members can import this dataset into their history for analysis' ] )
|
||||
self.logout()
|
||||
# regular_user1 is associated with role1, so should have all permissions on imported datasets
|
||||
self.login( email=regular_user1.email )
|
||||
@@ -423,7 +405,7 @@ class TestLibrarySecurity( TwillTestCase ):
|
||||
self.login( email=regular_user2.email )
|
||||
self.browse_library( 'library',
|
||||
self.security.encode_id( library1.id ),
|
||||
not_displayed=folder1.name )
|
||||
strings_not_displayed=[ folder1.name ] )
|
||||
self.logout()
|
||||
# regular_user3 is associated with role1, so should have all permissions on imported datasets
|
||||
self.login( email=regular_user3.email )
|
||||
@@ -437,12 +419,12 @@ class TestLibrarySecurity( TwillTestCase ):
|
||||
ldda_ids,
|
||||
str( role1.id ),
|
||||
permissions_in=[ 'DATASET_ACCESS' ],
|
||||
check_str1='Permissions updated for 3 datasets.' )
|
||||
strings_displayed=[ 'Permissions updated for 3 datasets.' ] )
|
||||
check_edit_page( latest_3_lddas,
|
||||
check_str1='View Permissions',
|
||||
not_displayed1='Manage dataset permissions on',
|
||||
not_displayed2='Role members can manage roles associated with permissions on this library item',
|
||||
not_displayed3='Role members can import this dataset into their history for analysis' )
|
||||
strings_displayed=[ 'View Permissions' ],
|
||||
strings_not_displayed=[ 'Manage dataset permissions on',
|
||||
'Role members can manage roles associated with permissions on this library item',
|
||||
'Role members can import this dataset into their history for analysis' ] )
|
||||
def test_060_restrict_access_to_library2( self ):
|
||||
"""Testing restricting access to library2"""
|
||||
# Logged in as admin_user
|
||||
@@ -471,16 +453,17 @@ class TestLibrarySecurity( TwillTestCase ):
|
||||
self.login( email=admin_user.email )
|
||||
def test_065_create_ldda6( self ):
|
||||
"""Testing create ldda6, restricting access on upload form to admin_user's private role"""
|
||||
self.add_library_dataset( 'library_admin',
|
||||
'6.bed',
|
||||
self.security.encode_id( library2.id ),
|
||||
self.security.encode_id( library2.root_folder.id ),
|
||||
library2.root_folder.name,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
roles=[ str( admin_user_private_role.id ) ],
|
||||
message='ldda6',
|
||||
root=False )
|
||||
filename = '6.bed'
|
||||
ldda_message = 'ldda6'
|
||||
self.upload_library_dataset( cntrller='library_admin',
|
||||
library_id=self.security.encode_id( library2.id ),
|
||||
folder_id=self.security.encode_id( library2.root_folder.id ),
|
||||
filename=filename,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
roles=[ str( admin_user_private_role.id ) ],
|
||||
ldda_message=ldda_message,
|
||||
strings_displayed=[ 'Upload files' ] )
|
||||
global ldda6
|
||||
ldda6 = get_latest_ldda()
|
||||
assert ldda6 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda6 from the database'
|
||||
@@ -500,16 +483,17 @@ class TestLibrarySecurity( TwillTestCase ):
|
||||
assert folder2 is not None, 'Problem retrieving folder2 from the database'
|
||||
def test_075_create_ldda7( self ):
|
||||
"""Testing create ldda7, restricting access on upload form to admin_user's private role"""
|
||||
self.add_library_dataset( 'library_admin',
|
||||
'7.bed',
|
||||
self.security.encode_id( library2.id ),
|
||||
self.security.encode_id( folder2.id ),
|
||||
folder2.name,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
roles=[ str( admin_user_private_role.id ) ],
|
||||
message='ldda7',
|
||||
root=False )
|
||||
filename = '7.bed'
|
||||
ldda_message = 'ldda7'
|
||||
self.upload_library_dataset( cntrller='library_admin',
|
||||
library_id=self.security.encode_id( library2.id ),
|
||||
folder_id=self.security.encode_id( folder2.id ),
|
||||
filename=filename,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
roles=[ str( admin_user_private_role.id ) ],
|
||||
ldda_message=ldda_message,
|
||||
strings_displayed=[ 'Upload files' ] )
|
||||
global ldda7
|
||||
ldda7 = get_latest_ldda()
|
||||
assert ldda7 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda7 from the database'
|
||||
@@ -528,16 +512,17 @@ class TestLibrarySecurity( TwillTestCase ):
|
||||
assert subfolder2 is not None, 'Problem retrieving subfolder2 from the database'
|
||||
def test_085_create_ldda8( self ):
|
||||
"""Testing create ldda8, restricting access on upload form to admin_user's private role"""
|
||||
self.add_library_dataset( 'library_admin',
|
||||
'8.bed',
|
||||
self.security.encode_id( library2.id ),
|
||||
self.security.encode_id( subfolder2.id ),
|
||||
subfolder2.name,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
roles=[ str( admin_user_private_role.id ) ],
|
||||
message='ldda8',
|
||||
root=False )
|
||||
filename = '8.bed'
|
||||
ldda_message = 'ldda8'
|
||||
self.upload_library_dataset( cntrller='library_admin',
|
||||
library_id=self.security.encode_id( library2.id ),
|
||||
folder_id=self.security.encode_id( subfolder2.id ),
|
||||
filename=filename,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
roles=[ str( admin_user_private_role.id ) ],
|
||||
ldda_message=ldda_message,
|
||||
strings_displayed=[ 'Upload files' ] )
|
||||
global ldda8
|
||||
ldda8 = get_latest_ldda()
|
||||
assert ldda8 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda8 from the database'
|
||||
@@ -555,9 +540,7 @@ class TestLibrarySecurity( TwillTestCase ):
|
||||
self.check_page_for_string( library2.name )
|
||||
self.browse_library( 'library',
|
||||
self.security.encode_id( library2.id ),
|
||||
check_str1=ldda6.name,
|
||||
check_str2=ldda7.name,
|
||||
check_str3=ldda8.name )
|
||||
strings_displayed=[ ldda6.name, ldda6.message, ldda7.name, ldda7.message, ldda8.name, ldda8.message ] )
|
||||
def test_999_reset_data_for_later_test_runs( self ):
|
||||
"""Reseting data to enable later test runs to pass"""
|
||||
# Logged in as regular_user2
|
||||
|
||||
@@ -110,56 +110,108 @@ class TestLibraryFeatures( TwillTestCase ):
|
||||
# Logged in as admin_user
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library1.id ),
|
||||
check_str1=folder1.name,
|
||||
check_str2=folder1.description )
|
||||
strings_displayed=[ folder1.name, folder1.description ] )
|
||||
# Make sure the template and contents were inherited to folder1
|
||||
self.folder_info( 'library_admin',
|
||||
self.security.encode_id( folder1.id ),
|
||||
self.security.encode_id( library1.id ),
|
||||
check_str1=AddressField_form.name,
|
||||
check_str2='This is an inherited template and is not required to be used with this folder' )
|
||||
def test_030_add_dataset_to_library1_folder( self ):
|
||||
"""
|
||||
Testing adding a new library dataset to library1's folder, and adding a new UserAddress
|
||||
on the upload form.
|
||||
"""
|
||||
strings_displayed=[ AddressField_form.name,
|
||||
'This is an inherited template and is not required to be used with this folder' ] )
|
||||
def test_030_add_dataset_to_folder1( self ):
|
||||
"""Testing adding a ldda1 to folder1, and adding a new UserAddress on the upload form."""
|
||||
# Logged in as admin_user
|
||||
# The AddressField template should be inherited to the library dataset upload form. Passing
|
||||
# the value 'new' should submit the form via refresh_on_change and allow new UserAddress information
|
||||
# to be posted as part of the upload.
|
||||
self.add_library_dataset( 'library_admin',
|
||||
'1.bed',
|
||||
self.security.encode_id( library1.id ),
|
||||
self.security.encode_id( folder1.id ),
|
||||
folder1.name,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
root=False,
|
||||
template_refresh_field_name='field_0',
|
||||
template_refresh_field_contents='new',
|
||||
field_0_short_desc='Office',
|
||||
field_0_name='Dick',
|
||||
field_0_institution='PSU',
|
||||
field_0_address='32 O Street',
|
||||
field_0_city='Anywhere',
|
||||
field_0_state='AK',
|
||||
field_0_postal_code='0000000',
|
||||
field_0_country='USA' )
|
||||
filename = '1.bed'
|
||||
ldda_message = '1.bed message'
|
||||
short_desc = 'Office'
|
||||
self.upload_library_dataset( cntrller='library_admin',
|
||||
library_id=self.security.encode_id( library1.id ),
|
||||
folder_id=self.security.encode_id( folder1.id ),
|
||||
filename=filename,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
ldda_message=ldda_message,
|
||||
template_refresh_field_contents='new',
|
||||
template_fields=[ ( 'field_0_short_desc', short_desc ),
|
||||
( 'field_0_name', 'Dick' ),
|
||||
( 'field_0_institution', 'PSU' ),
|
||||
( 'field_0_address', '32 O Street' ),
|
||||
( 'field_0_city', 'Anywhere' ),
|
||||
( 'field_0_state', 'AK' ),
|
||||
( 'field_0_postal_code', '0000000' ),
|
||||
( 'field_0_country', 'USA' ) ],
|
||||
strings_displayed=[ 'Upload files' ] )
|
||||
global user_address1
|
||||
user_address1 = get_user_address( admin_user, short_desc )
|
||||
assert user_address1 is not None, 'Problem retrieving user_address1 from the database'
|
||||
global ldda1
|
||||
ldda1 = get_latest_ldda()
|
||||
assert ldda1 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda1 from the database'
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library1.id ),
|
||||
check_str1='1.bed',
|
||||
check_str2=admin_user.email )
|
||||
strings_displayed=[ ldda1.name, ldda1.message, admin_user.email ] )
|
||||
# Make sure the library template contents were correctly saved
|
||||
self.ldda_edit_info( 'library_admin',
|
||||
self.security.encode_id( library1.id ),
|
||||
self.security.encode_id( folder1.id ),
|
||||
self.security.encode_id( ldda1.id ),
|
||||
ldda1.name,
|
||||
check_str1='Dick' )
|
||||
def test_035_add_template_to_library2( self ):
|
||||
strings_displayed=[ 'Dick' ] )
|
||||
def test_035_edit_contents_of_ldda1_tempplate( self ):
|
||||
"""Testing editing the contents of ldda1 AddressField template by adding a new user_address"""
|
||||
short_desc = 'Home'
|
||||
# Now add a new user_address to ldda1
|
||||
self.ldda_edit_info( 'library_admin',
|
||||
self.security.encode_id( library1.id ),
|
||||
self.security.encode_id( folder1.id ),
|
||||
self.security.encode_id( ldda1.id ),
|
||||
ldda1.name,
|
||||
template_refresh_field_contents='new',
|
||||
template_fields=[ ( 'field_0_short_desc', short_desc ),
|
||||
( 'field_0_name', 'Richard' ),
|
||||
( 'field_0_institution', 'PSU' ),
|
||||
( 'field_0_address', '32 O Street' ),
|
||||
( 'field_0_city', 'Anywhere' ),
|
||||
( 'field_0_state', 'AK' ),
|
||||
( 'field_0_postal_code', '0000000' ),
|
||||
( 'field_0_country', 'USA' ) ],
|
||||
strings_displayed=[ short_desc ] )
|
||||
global user_address2
|
||||
user_address2 = get_user_address( admin_user, short_desc )
|
||||
assert user_address2 is not None, 'Problem retrieving user_address2 from the database'
|
||||
def test_040_edit_contents_of_folder1_template( self ):
|
||||
"""Testing editing the contents of folder1 AddressField template"""
|
||||
# Make sure the template and contents were inherited to folder1
|
||||
self.folder_info( 'library_admin',
|
||||
self.security.encode_id( folder1.id ),
|
||||
self.security.encode_id( library1.id ),
|
||||
template_refresh_field_contents=str( user_address2.id ),
|
||||
strings_displayed=[ AddressField_form.name,
|
||||
'This is an inherited template and is not required to be used with this folder' ],
|
||||
strings_displayed_after_submit=[ 'Richard' ] )
|
||||
def test_045_add_dataset_to_folder1( self ):
|
||||
"""Testing adding another ldda to folder1"""
|
||||
# The upload form should now inherit user_address2 on the upload form
|
||||
filename = '2.bed'
|
||||
ldda_message = '2.bed message'
|
||||
self.upload_library_dataset( cntrller='library_admin',
|
||||
library_id=self.security.encode_id( library1.id ),
|
||||
folder_id=self.security.encode_id( folder1.id ),
|
||||
filename=filename,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
ldda_message=ldda_message,
|
||||
strings_displayed=[ 'Upload files' ] )
|
||||
# Make sure user_address2 is associated with ldda.
|
||||
self.ldda_edit_info( 'library_admin',
|
||||
self.security.encode_id( library1.id ),
|
||||
self.security.encode_id( folder1.id ),
|
||||
self.security.encode_id( ldda1.id ),
|
||||
ldda1.name,
|
||||
strings_displayed=[ user_address2.desc ] )
|
||||
def test_050_add_template_to_library2( self ):
|
||||
""" Testing add an inheritable template containing an CheckboxField to library2"""
|
||||
# Add a template containing an CheckboxField to library1
|
||||
self.add_library_template( 'library_admin',
|
||||
@@ -168,10 +220,10 @@ class TestLibraryFeatures( TwillTestCase ):
|
||||
self.security.encode_id( CheckboxField_form.id ),
|
||||
CheckboxField_form.name )
|
||||
# Check the CheckboxField to make sure the template contents are inherited
|
||||
self.set_library_info_field_template_field( 'library_admin',
|
||||
self.security.encode_id( library2.id ),
|
||||
field_value='1' )
|
||||
def test_040_add_folder_to_library2( self ):
|
||||
self.library_info( 'library_admin',
|
||||
self.security.encode_id( library2.id ),
|
||||
template_fields = [ ( 'field_0', '1' ) ] )
|
||||
def test_055_add_folder2_to_library2( self ):
|
||||
"""Testing adding a folder to library2"""
|
||||
# Logged in as admin_user
|
||||
# Add a folder to library2
|
||||
@@ -185,56 +237,51 @@ class TestLibraryFeatures( TwillTestCase ):
|
||||
description=description )
|
||||
global folder2
|
||||
folder2 = get_folder( folder.id, name, description )
|
||||
def test_045_check_library2( self ):
|
||||
def test_060_check_library2( self ):
|
||||
"""Checking library2 and its root folder"""
|
||||
# Logged in as admin_user
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library2.id ),
|
||||
check_str1=folder2.name,
|
||||
check_str2=folder2.description )
|
||||
def test_050_save_folder2_inherited_template( self ):
|
||||
strings_displayed=[ folder2.name, folder2.description ] )
|
||||
def test_065_save_folder2_inherited_template( self ):
|
||||
"""Saving the inherited template for folder2"""
|
||||
# Logged in as admin_user
|
||||
# Save the inherited template
|
||||
self.save_folder_template( 'library_admin',
|
||||
self.security.encode_id( folder2.id ),
|
||||
self.security.encode_id( library2.id ),
|
||||
field_name="field_0",
|
||||
field_value='1',
|
||||
check_str1=CheckboxField_form.name,
|
||||
check_str2='This is an inherited template and is not required to be used with this folder' )
|
||||
def test_055_add_dataset_to_library2_folder( self ):
|
||||
self.folder_info( cntrller='library_admin',
|
||||
folder_id=self.security.encode_id( folder2.id ),
|
||||
library_id=self.security.encode_id( library2.id ),
|
||||
template_fields=[ ( "field_0", '1' ) ],
|
||||
strings_displayed=[ CheckboxField_form.name,
|
||||
'This is an inherited template and is not required to be used with this folder' ] )
|
||||
def test_070_add_ldda_to_folder2( self ):
|
||||
"""
|
||||
Testing adding a new library dataset to library2's folder, making sure the CheckboxField is
|
||||
checked on the upload form.
|
||||
"""
|
||||
# Logged in as admin_user
|
||||
self.add_library_dataset( 'library_admin',
|
||||
'1.bed',
|
||||
self.security.encode_id( library2.id ),
|
||||
self.security.encode_id( folder2.id ),
|
||||
folder2.name,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
root=False,
|
||||
check_str1='CheckboxField',
|
||||
check_str2='checked' )
|
||||
global ldda2
|
||||
ldda2 = get_latest_ldda()
|
||||
assert ldda2 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda2 from the database'
|
||||
filename = '1.bed'
|
||||
ldda_message = '1.bed message'
|
||||
self.upload_library_dataset( cntrller='library_admin',
|
||||
library_id=self.security.encode_id( library2.id ),
|
||||
folder_id=self.security.encode_id( folder2.id ),
|
||||
filename=filename,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
ldda_message=ldda_message,
|
||||
strings_displayed=[ 'CheckboxField', 'checked' ] )
|
||||
ldda = get_latest_ldda()
|
||||
assert ldda is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda from the database'
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library2.id ),
|
||||
check_str1='1.bed',
|
||||
check_str2=admin_user.email )
|
||||
strings_displayed=[ ldda.name, ldda.message, admin_user.email ] )
|
||||
# Make sure the library template contents were correctly saved
|
||||
self.ldda_edit_info( 'library_admin',
|
||||
self.security.encode_id( library2.id ),
|
||||
self.security.encode_id( folder2.id ),
|
||||
self.security.encode_id( ldda2.id ),
|
||||
ldda2.name,
|
||||
check_str1='CheckboxField',
|
||||
check_str2='checked' )
|
||||
def test_060_add_template_to_library3( self ):
|
||||
self.security.encode_id( ldda.id ),
|
||||
ldda.name,
|
||||
strings_displayed=[ 'CheckboxField', 'checked' ] )
|
||||
def test_080_add_template_to_library3( self ):
|
||||
""" Testing add an inheritable template containing an SelectField to library3"""
|
||||
# Logged in as admin_user
|
||||
self.add_library_template( 'library_admin',
|
||||
@@ -243,10 +290,10 @@ class TestLibraryFeatures( TwillTestCase ):
|
||||
self.security.encode_id( SelectField_form.id ),
|
||||
SelectField_form.name )
|
||||
# Select the 2nd option in the SelectField to make sure the template contents are inherited
|
||||
self.set_library_info_field_template_field( 'library_admin',
|
||||
self.security.encode_id( library3.id ),
|
||||
field_value='Two' )
|
||||
def test_065_add_folder_to_library3( self ):
|
||||
self.library_info( 'library_admin',
|
||||
self.security.encode_id( library3.id ),
|
||||
template_fields=[ ( 'field_0', 'Two' ) ] )
|
||||
def test_085_add_folder3_to_library3( self ):
|
||||
"""Testing adding a folder to library3"""
|
||||
# Logged in as admin_user
|
||||
# Add a folder to library3
|
||||
@@ -260,57 +307,52 @@ class TestLibraryFeatures( TwillTestCase ):
|
||||
description=description )
|
||||
global folder3
|
||||
folder3 = get_folder( folder.id, name, description )
|
||||
def test_070_check_library3( self ):
|
||||
def test_090_check_library3( self ):
|
||||
"""Checking library3 and its root folder"""
|
||||
# Logged in as admin_user
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library3.id ),
|
||||
check_str1=folder3.name,
|
||||
check_str2=folder3.description )
|
||||
def test_075_save_folder3_inherited_template( self ):
|
||||
strings_displayed=[ folder3.name, folder3.description ] )
|
||||
def test_095_save_folder3_inherited_template( self ):
|
||||
"""Saving the inherited template for folder3"""
|
||||
# Logged in as admin_user
|
||||
# Save the inherited template
|
||||
self.save_folder_template( 'library_admin',
|
||||
self.security.encode_id( folder3.id ),
|
||||
self.security.encode_id( library3.id ),
|
||||
field_name="field_0",
|
||||
field_value='Two',
|
||||
check_str1=SelectField_form.name,
|
||||
check_str2='This is an inherited template and is not required to be used with this folder',
|
||||
check_str3='Two' )
|
||||
def test_080_add_dataset_to_library3_folder( self ):
|
||||
self.folder_info( cntrller='library_admin',
|
||||
folder_id=self.security.encode_id( folder3.id ),
|
||||
library_id=self.security.encode_id( library3.id ),
|
||||
template_fields=[ ( "field_0", 'Two' ) ],
|
||||
strings_displayed=[ SelectField_form.name,
|
||||
'This is an inherited template and is not required to be used with this folder',
|
||||
'Two' ] )
|
||||
def test_100_add_ldda_to_folder3( self ):
|
||||
"""
|
||||
Testing adding a new library dataset to library3's folder,
|
||||
making sure the SelectField setting is correct on the upload form.
|
||||
"""
|
||||
filename = '3.bed'
|
||||
ldda_message = '3.bed message'
|
||||
# Logged in as admin_user
|
||||
self.add_library_dataset( 'library_admin',
|
||||
'1.bed',
|
||||
self.security.encode_id( library3.id ),
|
||||
self.security.encode_id( folder3.id ),
|
||||
folder3.name,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
root=False,
|
||||
check_str1='SelectField',
|
||||
check_str2='selected>Two' )
|
||||
global ldda3
|
||||
ldda3 = get_latest_ldda()
|
||||
assert ldda3 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda3 from the database'
|
||||
self.upload_library_dataset( cntrller='library_admin',
|
||||
library_id=self.security.encode_id( library3.id ),
|
||||
folder_id=self.security.encode_id( folder3.id ),
|
||||
filename=filename,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
ldda_message=ldda_message,
|
||||
strings_displayed=[ 'SelectField', 'selected>Two' ] )
|
||||
ldda = get_latest_ldda()
|
||||
assert ldda is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda from the database'
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library3.id ),
|
||||
check_str1='1.bed',
|
||||
check_str2=admin_user.email )
|
||||
strings_displayed=[ ldda.name, ldda.message, admin_user.email ] )
|
||||
# Make sure the library template contents were correctly saved
|
||||
self.ldda_edit_info( 'library_admin',
|
||||
self.security.encode_id( library3.id ),
|
||||
self.security.encode_id( folder3.id ),
|
||||
self.security.encode_id( ldda3.id ),
|
||||
ldda3.name,
|
||||
check_str1='SelectField',
|
||||
check_str2='Two' )
|
||||
def test_085_add_template_to_library4( self ):
|
||||
self.security.encode_id( ldda.id ),
|
||||
ldda.name,
|
||||
strings_displayed=[ 'SelectField', 'Two' ] )
|
||||
def test_105_add_template_to_library4( self ):
|
||||
""" Testing add an inheritable template containing an TextArea to library4"""
|
||||
# Logged in as admin_user
|
||||
# Add an inheritable template to library4
|
||||
@@ -320,10 +362,10 @@ class TestLibraryFeatures( TwillTestCase ):
|
||||
self.security.encode_id( TextArea_form.id ),
|
||||
TextArea_form.name )
|
||||
# Select the 2nd option in the SelectField to make sure the template contents are inherited
|
||||
self.set_library_info_field_template_field( 'library_admin',
|
||||
self.security.encode_id( library4.id ),
|
||||
field_value='This text should be inherited' )
|
||||
def test_090_add_folder_to_library4( self ):
|
||||
self.library_info( 'library_admin',
|
||||
self.security.encode_id( library4.id ),
|
||||
template_fields=[ ('field_0', 'This text should be inherited' ) ] )
|
||||
def test_110_add_folder4_to_library4( self ):
|
||||
"""Testing adding a folder to library4"""
|
||||
# Logged in as admin_user
|
||||
# Add a folder to library4
|
||||
@@ -337,50 +379,46 @@ class TestLibraryFeatures( TwillTestCase ):
|
||||
description=description )
|
||||
global folder4
|
||||
folder4 = get_folder( folder.id, name, description )
|
||||
def test_095_save_folder4_inherited_template( self ):
|
||||
def test_115_save_folder4_inherited_template( self ):
|
||||
"""Saving the inherited template for folder4"""
|
||||
# Logged in as admin_user
|
||||
# Save the inherited template
|
||||
self.save_folder_template( 'library_admin',
|
||||
self.security.encode_id( folder4.id ),
|
||||
self.security.encode_id( library4.id ),
|
||||
field_name="field_0",
|
||||
field_value='This text should be inherited',
|
||||
check_str1=TextArea_form.name,
|
||||
check_str2='This is an inherited template and is not required to be used with this folder',
|
||||
check_str3='This text should be inherited' )
|
||||
def test_100_add_dataset_to_library4_folder( self ):
|
||||
self.folder_info( cntrller='library_admin',
|
||||
folder_id=self.security.encode_id( folder4.id ),
|
||||
library_id=self.security.encode_id( library4.id ),
|
||||
template_fields=[ ( "field_0", 'This text should be inherited' ) ],
|
||||
strings_displayed=[ TextArea_form.name,
|
||||
'This is an inherited template and is not required to be used with this folder',
|
||||
'This text should be inherited' ] )
|
||||
def test_120_add_ldda_to_folder4( self ):
|
||||
"""
|
||||
Testing adding a new library dataset to library4's folder,
|
||||
making sure the TextArea setting is correct on the upload form.
|
||||
"""
|
||||
filename = '4.bed'
|
||||
ldda_message = '4.bed message'
|
||||
# Logged in as admin_user
|
||||
self.add_library_dataset( 'library_admin',
|
||||
'1.bed',
|
||||
self.security.encode_id( library4.id ),
|
||||
self.security.encode_id( folder4.id ),
|
||||
folder4.name,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
root=False,
|
||||
check_str1='TextArea',
|
||||
check_str2='This text should be inherited' )
|
||||
global ldda4
|
||||
ldda4 = get_latest_ldda()
|
||||
assert ldda4 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda4 from the database'
|
||||
self.upload_library_dataset( cntrller='library_admin',
|
||||
library_id=self.security.encode_id( library4.id ),
|
||||
folder_id=self.security.encode_id( folder4.id ),
|
||||
filename=filename,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
ldda_message=ldda_message,
|
||||
strings_displayed=[ 'TextArea', 'This text should be inherited' ] )
|
||||
ldda = get_latest_ldda()
|
||||
assert ldda is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda from the database'
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library4.id ),
|
||||
check_str1='1.bed',
|
||||
check_str2=admin_user.email )
|
||||
strings_displayed=[ ldda.name, ldda.message, admin_user.email ] )
|
||||
# Make sure the library template contents were correctly saved
|
||||
self.ldda_edit_info( 'library_admin',
|
||||
self.security.encode_id( library4.id ),
|
||||
self.security.encode_id( folder4.id ),
|
||||
self.security.encode_id( ldda4.id ),
|
||||
ldda4.name,
|
||||
check_str1='TextArea',
|
||||
check_str2='This text should be inherited' )
|
||||
def test_105_add_template_to_library5( self ):
|
||||
self.security.encode_id( ldda.id ),
|
||||
ldda.name,
|
||||
strings_displayed=[ 'TextArea', 'This text should be inherited' ] )
|
||||
def test_125_add_template_to_library5( self ):
|
||||
""" Testing add an inheritable template containing an TextField to library5"""
|
||||
# Add an inheritable template to library5
|
||||
self.add_library_template( 'library_admin',
|
||||
@@ -389,10 +427,10 @@ class TestLibraryFeatures( TwillTestCase ):
|
||||
self.security.encode_id( TextField_form.id ),
|
||||
TextField_form.name )
|
||||
# Select the 2nd option in the SelectField to make sure the template contents are inherited
|
||||
self.set_library_info_field_template_field( 'library_admin',
|
||||
self.security.encode_id( library5.id ),
|
||||
field_value='This text should be inherited' )
|
||||
def test_110_add_folder_to_library5( self ):
|
||||
self.library_info( 'library_admin',
|
||||
self.security.encode_id( library5.id ),
|
||||
template_fields=[ ( 'field_0', 'This text should be inherited' ) ] )
|
||||
def test_130_add_folder5_to_library5( self ):
|
||||
"""Testing adding a folder to library5"""
|
||||
# Logged in as admin_user
|
||||
# Add a folder to library5
|
||||
@@ -406,50 +444,46 @@ class TestLibraryFeatures( TwillTestCase ):
|
||||
description=description )
|
||||
global folder5
|
||||
folder5 = get_folder( folder.id, name, description )
|
||||
def test_115_save_folder5_inherited_template( self ):
|
||||
def test_135_save_folder5_inherited_template( self ):
|
||||
"""Saving the inherited template for folder5"""
|
||||
# Logged in as admin_user
|
||||
# Save the inherited template
|
||||
self.save_folder_template( 'library_admin',
|
||||
self.security.encode_id( folder5.id ),
|
||||
self.security.encode_id( library5.id ),
|
||||
field_name="field_0",
|
||||
field_value='This text should be inherited',
|
||||
check_str1=TextField_form.name,
|
||||
check_str2='This is an inherited template and is not required to be used with this folder',
|
||||
check_str3='This text should be inherited' )
|
||||
def test_120_add_dataset_to_library5_folder( self ):
|
||||
self.folder_info( cntrller='library_admin',
|
||||
folder_id=self.security.encode_id( folder5.id ),
|
||||
library_id=self.security.encode_id( library5.id ),
|
||||
template_fields=[ ( "field_0", 'This text should be inherited' ) ],
|
||||
strings_displayed=[ TextField_form.name,
|
||||
'This is an inherited template and is not required to be used with this folder',
|
||||
'This text should be inherited' ] )
|
||||
def test_140_add_ldda_to_folder5( self ):
|
||||
"""
|
||||
Testing adding a new library dataset to library5's folder,
|
||||
making sure the TextField setting is correct on the upload form.
|
||||
"""
|
||||
# Logged in as admin_user
|
||||
self.add_library_dataset( 'library_admin',
|
||||
'1.bed',
|
||||
self.security.encode_id( library5.id ),
|
||||
self.security.encode_id( folder5.id ),
|
||||
folder5.name,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
root=False,
|
||||
check_str1='TextField',
|
||||
check_str2='This text should be inherited' )
|
||||
global ldda5
|
||||
ldda5 = get_latest_ldda()
|
||||
assert ldda5 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda5 from the database'
|
||||
filename = '5.bed'
|
||||
ldda_message = '5.bed message'
|
||||
self.upload_library_dataset( cntrller='library_admin',
|
||||
library_id=self.security.encode_id( library5.id ),
|
||||
folder_id=self.security.encode_id( folder5.id ),
|
||||
filename=filename,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
ldda_message=ldda_message,
|
||||
strings_displayed=[ 'TextField', 'This text should be inherited' ] )
|
||||
ldda = get_latest_ldda()
|
||||
assert ldda is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda from the database'
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library5.id ),
|
||||
check_str1='1.bed',
|
||||
check_str2=admin_user.email )
|
||||
strings_displayed=[ ldda.name, ldda.message, admin_user.email ] )
|
||||
# Make sure the library template contents were correctly saved
|
||||
self.ldda_edit_info( 'library_admin',
|
||||
self.security.encode_id( library5.id ),
|
||||
self.security.encode_id( folder5.id ),
|
||||
self.security.encode_id( ldda5.id ),
|
||||
ldda5.name,
|
||||
check_str1='TextField',
|
||||
check_str2='This text should be inherited' )
|
||||
def test_125_edit_library5_template_layout( self ):
|
||||
self.security.encode_id( ldda.id ),
|
||||
ldda.name,
|
||||
strings_displayed=[ 'TextField', 'This text should be inherited' ] )
|
||||
def test_145_edit_library5_template_layout( self ):
|
||||
"""Test editing the layout of library5's template"""
|
||||
# Currently there is only a TextField, and we'll add a TextArea.
|
||||
self.edit_template( 'library_admin',
|
||||
@@ -459,41 +493,40 @@ class TestLibraryFeatures( TwillTestCase ):
|
||||
field_name_1=TextArea_form.name,
|
||||
field_helptext_1='%s help' % TextArea_form.name,
|
||||
field_default_1='%s default' % TextArea_form.name )
|
||||
def test_130_add_dataset_to_library5( self ):
|
||||
def test_150_add_ldda_to_library5( self ):
|
||||
"""
|
||||
Testing adding a new library dataset to library5's folder,
|
||||
making sure the TextField and new TextArea settings are
|
||||
correct on the upload form.
|
||||
"""
|
||||
filename = '6.bed'
|
||||
ldda_message = '6.bed message'
|
||||
# Logged in as admin_user
|
||||
self.add_library_dataset( 'library_admin',
|
||||
'2.bed',
|
||||
self.security.encode_id( library5.id ),
|
||||
self.security.encode_id( library5.root_folder.id ),
|
||||
library5.root_folder.name,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
root=True,
|
||||
check_str1='TextField',
|
||||
check_str2='This text should be inherited',
|
||||
check_str3='TextArea' )
|
||||
global ldda5a
|
||||
ldda5a = get_latest_ldda()
|
||||
assert ldda5a is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda5a from the database'
|
||||
self.upload_library_dataset( cntrller='library_admin',
|
||||
library_id=self.security.encode_id( library5.id ),
|
||||
folder_id=self.security.encode_id( library5.root_folder.id ),
|
||||
filename=filename,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
ldda_message=ldda_message,
|
||||
strings_displayed=[ 'TextField',
|
||||
'This text should be inherited',
|
||||
'TextArea' ] )
|
||||
ldda = get_latest_ldda()
|
||||
assert ldda is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda from the database'
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library5.id ),
|
||||
check_str1='1.bed',
|
||||
check_str2=admin_user.email )
|
||||
strings_displayed=[ ldda.name, ldda.message, admin_user.email ] )
|
||||
# Make sure the library template contents were correctly saved
|
||||
self.ldda_edit_info( 'library_admin',
|
||||
self.security.encode_id( library5.id ),
|
||||
self.security.encode_id( library5.root_folder.id ),
|
||||
self.security.encode_id( ldda5a.id ),
|
||||
ldda5a.name,
|
||||
check_str1='TextField',
|
||||
check_str2='This text should be inherited',
|
||||
check_str3='TextArea' )
|
||||
def test_135_add_template_to_library6( self ):
|
||||
self.security.encode_id( ldda.id ),
|
||||
ldda.name,
|
||||
strings_displayed=[ 'TextField',
|
||||
'This text should be inherited',
|
||||
'TextArea' ] )
|
||||
def test_155_add_template_to_library6( self ):
|
||||
""" Testing add an inheritable template containing an WorkflowField to library6"""
|
||||
# Add an inheritable template to library6
|
||||
# We won't select an option since we have no workflow to select
|
||||
@@ -502,7 +535,7 @@ class TestLibraryFeatures( TwillTestCase ):
|
||||
self.security.encode_id( library6.id ),
|
||||
self.security.encode_id( WorkflowField_form.id ),
|
||||
WorkflowField_form.name )
|
||||
def test_140_add_folder_to_library6( self ):
|
||||
def test_160_add_folder6_to_library6( self ):
|
||||
"""Testing adding a folder to library6"""
|
||||
# Logged in as admin_user
|
||||
# Add a folder to library5
|
||||
@@ -516,52 +549,47 @@ class TestLibraryFeatures( TwillTestCase ):
|
||||
description=description )
|
||||
global folder6
|
||||
folder6 = get_folder( folder.id, name, description )
|
||||
def test_145_save_folder6_inherited_template( self ):
|
||||
def test_165_save_folder6_inherited_template( self ):
|
||||
"""Saving the inherited template for folder6"""
|
||||
# Logged in as admin_user
|
||||
# Save the inherited template - we won't select an option since we have no workflow to select
|
||||
self.save_folder_template( 'library_admin',
|
||||
self.security.encode_id( folder6.id ),
|
||||
self.security.encode_id( library6.id ),
|
||||
field_name="field_0",
|
||||
field_value='none',
|
||||
check_str1=WorkflowField_form.name,
|
||||
check_str2='This is an inherited template and is not required to be used with this folder',
|
||||
check_str3='none' )
|
||||
def test_150_add_dataset_to_library6_folder( self ):
|
||||
self.folder_info( cntrller='library_admin',
|
||||
folder_id=self.security.encode_id( folder6.id ),
|
||||
library_id=self.security.encode_id( library6.id ),
|
||||
template_fields=[ ( "field_0", 'none' ) ],
|
||||
strings_displayed=[ WorkflowField_form.name,
|
||||
'This is an inherited template and is not required to be used with this folder',
|
||||
'none' ] )
|
||||
def test_170_add_ldda_to_folder6( self ):
|
||||
"""
|
||||
Testing adding a new library dataset to library6's folder,
|
||||
making sure the WorkflowField setting is correct on the upload form.
|
||||
"""
|
||||
# Logged in as admin_user
|
||||
self.add_library_dataset( 'library_admin',
|
||||
'1.bed',
|
||||
self.security.encode_id( library6.id ),
|
||||
self.security.encode_id( folder6.id ),
|
||||
folder6.name,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
root=False,
|
||||
check_str1='WorkflowField',
|
||||
check_str2='none' )
|
||||
global ldda6
|
||||
ldda6 = get_latest_ldda()
|
||||
assert ldda6 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda6 from the database'
|
||||
filename = '7.bed'
|
||||
ldda_message = '7.bed message'
|
||||
self.upload_library_dataset( cntrller='library_admin',
|
||||
library_id=self.security.encode_id( library6.id ),
|
||||
folder_id=self.security.encode_id( folder6.id ),
|
||||
filename=filename,
|
||||
file_type='bed',
|
||||
dbkey='hg18',
|
||||
ldda_message=ldda_message,
|
||||
strings_displayed=[ 'WorkflowField', 'none' ] )
|
||||
ldda = get_latest_ldda()
|
||||
assert ldda is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda from the database'
|
||||
self.browse_library( 'library_admin',
|
||||
self.security.encode_id( library6.id ),
|
||||
check_str1='1.bed',
|
||||
check_str2=admin_user.email )
|
||||
strings_displayed=[ ldda.name, ldda.message, admin_user.email ] )
|
||||
# Make sure the library template contents were correctly saved
|
||||
self.ldda_edit_info( 'library_admin',
|
||||
self.security.encode_id( library6.id ),
|
||||
self.security.encode_id( folder6.id ),
|
||||
self.security.encode_id( ldda6.id ),
|
||||
ldda6.name,
|
||||
check_str1='WorkflowField',
|
||||
check_str2='none' )
|
||||
self.security.encode_id( ldda.id ),
|
||||
ldda.name,
|
||||
strings_displayed=[ 'WorkflowField', 'none' ] )
|
||||
def test_999_reset_data_for_later_test_runs( self ):
|
||||
"""Reseting data to enable later test runs to pass"""
|
||||
"""
|
||||
# Logged in as admin_user
|
||||
##################
|
||||
# Delete all form definitions
|
||||
@@ -569,6 +597,11 @@ class TestLibraryFeatures( TwillTestCase ):
|
||||
for form in [ AddressField_form, CheckboxField_form, SelectField_form, TextArea_form, TextField_form, WorkflowField_form ]:
|
||||
self.mark_form_deleted( self.security.encode_id( form.form_definition_current.id ) )
|
||||
##################
|
||||
# Mark all user_addresses deleted
|
||||
##################
|
||||
for user_address in [ user_address1, user_address2 ]:
|
||||
mark_obj_deleted( user_address )
|
||||
##################
|
||||
# Purge all libraries
|
||||
##################
|
||||
for library in [ library1, library2, library3, library4, library5, library6 ]:
|
||||
@@ -586,4 +619,3 @@ class TestLibraryFeatures( TwillTestCase ):
|
||||
if len( user.roles) != 1:
|
||||
raise AssertionError( '%d UserRoleAssociations are associated with %s ( should be 1 )' % ( len( user.roles ), user.email ) )
|
||||
self.logout()
|
||||
"""
|
||||
@@ -1,13 +1,8 @@
|
||||
from base.twilltestcase import *
|
||||
from base.test_db_util import *
|
||||
|
||||
not_logged_in_as_admin_security_msg = 'You must be logged in as an administrator to access this feature.'
|
||||
logged_in_as_admin_security_msg = 'You must be an administrator to access this feature.'
|
||||
not_logged_in_security_msg = 'You must be logged in to create/submit sequencing requests'
|
||||
global form_one_name
|
||||
form_one_name = "Student"
|
||||
global form_two_name
|
||||
form_two_name = "Researcher"
|
||||
# TODO: ( gvk: 9/17/10 ) The code in this script was so horribly written that it could not be maintained. I will fix the worst code
|
||||
# as soon as I get a chance. I've already gotten started, but have run out of time so I'm commenting out the broken tests for now...
|
||||
|
||||
class TestUserInfo( TwillTestCase ):
|
||||
def test_000_initiate_users( self ):
|
||||
@@ -40,16 +35,18 @@ class TestUserInfo( TwillTestCase ):
|
||||
assert admin_user is not None, 'Problem retrieving user with email "test@bx.psu.edu" from the database'
|
||||
global admin_user_private_role
|
||||
admin_user_private_role = get_private_role( admin_user )
|
||||
"""
|
||||
def test_005_create_user_info_forms( self ):
|
||||
"""Testing creating a new user info form and editing it"""
|
||||
Testing creating a new user info form and editing it
|
||||
# Logged in as admin_user
|
||||
# Create a the first form
|
||||
name = form_one_name
|
||||
name = "Student"
|
||||
desc = "This is Student user info form's description"
|
||||
formtype = get_user_info_form_definition()
|
||||
self.create_form( name=name, desc=desc, formtype=formtype, num_fields=0 )
|
||||
# Get the form_definition object for later tests
|
||||
form_one = get_form( form_one_name )
|
||||
global form_one
|
||||
form_one = get_form( name )
|
||||
assert form_one is not None, 'Problem retrieving form named "%s" from the database' % name
|
||||
# edit form & add few more fields
|
||||
fields = [dict(name='Affiliation',
|
||||
@@ -71,14 +68,15 @@ class TestUserInfo( TwillTestCase ):
|
||||
form_one.type,
|
||||
field_index=len( form_one.fields ),
|
||||
fields=fields)
|
||||
form_one_latest = get_form( form_one_name )
|
||||
form_one_latest = get_form( form_one.name )
|
||||
assert len( form_one_latest.fields ) == len( form_one.fields ) + len( fields )
|
||||
# create the second form
|
||||
name = form_two_name
|
||||
name = "Researcher"
|
||||
desc = "This is Researcher user info form's description"
|
||||
self.create_form( name=name, desc=desc, formtype=formtype, num_fields=0 )
|
||||
# Get the form_definition object for later tests
|
||||
form_two = get_form( form_two_name )
|
||||
global form_two
|
||||
form_two = get_form( name )
|
||||
assert form_two is not None, 'Problem retrieving form named "%s" from the database' % name
|
||||
# edit form & add few more fields
|
||||
fields = [dict(name='Affiliation',
|
||||
@@ -100,15 +98,14 @@ class TestUserInfo( TwillTestCase ):
|
||||
form_two.type,
|
||||
field_index=len( form_one.fields ),
|
||||
fields=fields )
|
||||
form_two_latest = get_form( form_two_name )
|
||||
form_two_latest = get_form( form_two.name )
|
||||
assert len( form_two_latest.fields ) == len( form_two.fields ) + len( fields )
|
||||
def test_010_user_reqistration_multiple_user_info_forms( self ):
|
||||
''' Testing user registration with multiple user info forms '''
|
||||
Testing user registration with multiple user info forms
|
||||
# Logged in as admin_user
|
||||
self.logout()
|
||||
# Create a new user with 'Student' user info form
|
||||
form_one = get_form(form_one_name)
|
||||
user_info_values=['Educational', 'Penn State', True]
|
||||
user_info_values=[ 'Educational', 'Penn State', True ]
|
||||
self.create_user_with_info( 'test11@bx.psu.edu',
|
||||
'testuser',
|
||||
'test11',
|
||||
@@ -128,17 +125,15 @@ class TestUserInfo( TwillTestCase ):
|
||||
self.check_page_for_string( user_info_values[1] )
|
||||
self.check_page_for_string( '<input type="checkbox" name="field_2" value="true" checked>' )
|
||||
def test_015_user_reqistration_single_user_info_forms( self ):
|
||||
''' Testing user registration with a single user info form '''
|
||||
Testing user registration with a single user info form
|
||||
# Logged in as regular_user_11
|
||||
self.logout()
|
||||
self.login( email=admin_user.email )
|
||||
# Delete the 'Researcher' user info form
|
||||
form_two_latest = get_form( form_two_name )
|
||||
mark_form_deleted( form_two_latest )
|
||||
mark_form_deleted( form_two )
|
||||
self.visit_url( '%s/forms/manage?sort=create_time&f-deleted=True' % self.url )
|
||||
self.check_page_for_string( form_two_latest.name )
|
||||
self.check_page_for_string( form_two.name )
|
||||
# Create a new user with 'Student' user info form
|
||||
form_one = get_form( form_one_name )
|
||||
user_info_values=['Educational', 'Penn State', True]
|
||||
self.create_user_with_info( 'test12@bx.psu.edu', 'testuser', 'test12',
|
||||
user_info_forms='single',
|
||||
@@ -157,16 +152,16 @@ class TestUserInfo( TwillTestCase ):
|
||||
self.check_page_for_string( user_info_values[1] )
|
||||
self.check_page_for_string( '<input type="checkbox" name="field_2" value="true" checked>' )
|
||||
def test_020_edit_user_info( self ):
|
||||
"""Testing editing user info as a regular user"""
|
||||
Testing editing user info as a regular user
|
||||
# Logged in as regular_user_12
|
||||
# Test changing email and user name - first try an invalid user name
|
||||
self.edit_login_info( new_email='test12_new@bx.psu.edu',
|
||||
new_username='test12_new',
|
||||
check_str1="User name must contain only lower-case letters, numbers and '-'" )
|
||||
strings_displayed=[ "User name must contain only lower-case letters, numbers and '-'" ] )
|
||||
# Now try a valid user name
|
||||
self.edit_login_info( new_email='test12_new@bx.psu.edu',
|
||||
new_username='test12-new',
|
||||
check_str1='The login information has been updated with the changes' )
|
||||
strings_displayed=[ 'The login information has been updated with the changes' ] )
|
||||
# Since we changed the user's account. make sure the user's private role was changed accordingly
|
||||
if not get_private_role( regular_user12 ):
|
||||
raise AssertionError, "The private role for %s was not correctly set when their account (email) was changed" % regular_user12.email
|
||||
@@ -179,16 +174,15 @@ class TestUserInfo( TwillTestCase ):
|
||||
# Test editing the user info
|
||||
self.edit_user_info( ['Research', 'PSU'] )
|
||||
def test_999_reset_data_for_later_test_runs( self ):
|
||||
"""Reseting data to enable later test runs to pass"""
|
||||
Reseting data to enable later test runs to pass
|
||||
# Logged in as regular_user_12
|
||||
self.logout()
|
||||
self.login( email=admin_user.email )
|
||||
##################
|
||||
# Mark all forms deleted
|
||||
##################
|
||||
for form_name in [ form_one_name ]:
|
||||
form = get_form( form_name )
|
||||
mark_form_deleted( form )
|
||||
for form in [ form_one, form_two ]:
|
||||
self.mark_form_deleted( form )
|
||||
###############
|
||||
# Purge appropriate users
|
||||
###############
|
||||
@@ -199,3 +193,4 @@ class TestUserInfo( TwillTestCase ):
|
||||
refresh( user )
|
||||
delete_user_roles( user )
|
||||
delete_obj( user )
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user