galaxy-dist commit 8ce82d60b2ab: - added the change data library sample operation functional test.
# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User rc # Date 1290011634 18000 # Node ID 8ce82d60b2ab55966d133db136fcb2f809201c4b # Parent 19b10fff133595cb5cd1851a7f24024c2637ad2b - added the change data library sample operation functional test. - renaming dataset now checks for incorrect filename characters - fixed bugs --- a/lib/galaxy/web/controllers/requests_common.py +++ b/lib/galaxy/web/controllers/requests_common.py @@ -1079,7 +1079,7 @@ class RequestsCommon( BaseController, Us cntrller=cntrller, action='update_request_state', request_id=trans.security.encode_id( request.id ) ) ) - elif sample_operation == trans.model.sample.bulk_operations.SELECT_LIBRARY: + elif sample_operation == trans.model.Sample.bulk_operations.SELECT_LIBRARY: # TODO: fix the code so that the sample_operation_select_field does not use # sample_0_library_id as it's name. it should use something like sample_operation_library_id # and sample_operation_folder_id because the name sample_0_library_id should belong to the --- a/templates/admin/requests/rename_datasets.mako +++ b/templates/admin/requests/rename_datasets.mako @@ -16,6 +16,7 @@ <div class="toolForm"><form name="rename_datasets" id="rename_datasets" action="${h.url_for( controller='requests_admin', action='rename_datasets', id_list=id_list, sample_id=trans.security.encode_id( sample.id ) )}" method="post" > + <table class="grid"><thead><tr> @@ -43,9 +44,16 @@ </tbody></table><br/> + <div class="form-row"> + <div class="toolParamHelp" style="clear: both;"> + A dataset name should only contain the alphanumeric characters or underscore(_). + If a dataset name contains any other character, it would be replaced by an underscore(_). + </div> + </div><div class="form-row"><input type="submit" name="rename_datasets_button" value="Save"/><input type="submit" name="cancel_rename_datasets_button" value="Close"/></div></form> + </div> --- a/scripts/galaxy_messaging/server/setup_rabbitmq.py +++ b/scripts/galaxy_messaging/server/setup_rabbitmq.py @@ -24,7 +24,7 @@ def main( config_file ): cmd_list = [ 'add_user %s %s' % ( username, password ), - 'add_vhost %s' % config.get( 'galaxy_amqp', 'virtual_host' ), + 'add_vhost %s' % virtual_host, 'set_permissions -p %s %s ".*" ".*" ".*"' % ( virtual_host, username ) ] --- a/test/functional/test_sample_tracking.py +++ b/test/functional/test_sample_tracking.py @@ -430,8 +430,8 @@ class TestFormsAndRequests( TwillTestCas """Testing editing the sample information of new request1""" # logged in as regular_user1 # target data library - change it to library1 - target_library_info = dict(library=self.security.encode_id(library1.id), - folder=self.security.encode_id(library1_folder1.id) ) + target_library_info = dict(library=self.security.encode_id( library1.id ), + folder=self.security.encode_id( library1_folder1.id ) ) new_sample_value_tuples = \ [ ( 'Sample1_renamed', target_library_info, [ 'option2', 'sample1 field2 value edited', 'sample1 field3 value edited' ] ), ( 'Sample2_renamed', target_library_info, [ 'option1', 'sample2 field2 value edited', 'sample2 field3 value edited' ] ), @@ -494,6 +494,23 @@ class TestFormsAndRequests( TwillTestCas strings_displayed_count=strings_displayed_count, strings_not_displayed=[ request1.states.COMPLETE, request1.states.REJECTED ] ) + # change the target data library back to library2 using sample operation user interface + self.change_sample_target_data_library( cntrller='requests', + request_id=self.security.encode_id( request1.id ), + sample_ids=[ sample.id for sample in request1.samples ], + new_library_id=self.security.encode_id( library2.id ), + new_folder_id=self.security.encode_id( library2_folder1.id ), + strings_displayed=[ 'Edit Current Samples of Sequencing Request "%s"' % request1.name ], + strings_displayed_after_submit=[ 'Changes made to the samples have been saved.' ] ) + # check the changed target data library & folder on the request page + strings_displayed_count = [] + strings_displayed_count.append( ( library2.name, len( request1.samples ) ) ) + strings_displayed_count.append( ( library2_folder1.name, len( request1.samples ) ) ) + self.view_request( cntrller='requests', + request_id=self.security.encode_id( request1.id ), + strings_displayed=[], + strings_displayed_count=strings_displayed_count ) + # # ====== Sequencing request test methods - Admin perspective ================ # @@ -537,7 +554,7 @@ class TestFormsAndRequests( TwillTestCas request1.type.states[4].desc ] # check history of each sample for sample in request1.samples: - strings_displayed = [ 'Events for Sample "%s"' % sample.name, + strings_displayed = [ 'History of sample "%s"' % sample.name, 'Sequencing request submitted and sample state set to %s' % request1.type.states[0].name, request1.type.states[0].name, request1.type.states[1].name ] --- a/lib/galaxy/web/controllers/requests_admin.py +++ b/lib/galaxy/web/controllers/requests_admin.py @@ -361,17 +361,29 @@ class RequestsAdmin( BaseController, Use sample_dataset = trans.sa_session.query( trans.app.model.SampleDataset ).get( trans.security.decode_id( sample_dataset_id ) ) sample_datasets.append( sample_dataset ) if params.get( 'rename_datasets_button', False ): + incorrect_dataset_names = [] for sample_dataset in sample_datasets: encoded_id = trans.security.encode_id( sample_dataset.id ) selected_option = util.restore_text( params.get( 'rename_datasets_for_sample_%s' % encoded_id, '' ) ) new_name = util.restore_text( params.get( 'new_name_%s' % encoded_id, '' ) ) + if not new_name: + incorrect_dataset_names.append( sample_dataset.name ) + continue + new_name = util.sanitize_for_filename( new_name ) if selected_option == 'none': sample_dataset.name = new_name else: sample_dataset.name = '%s_%s' % ( selected_option, new_name ) trans.sa_session.add( sample_dataset ) trans.sa_session.flush() - message = 'Changes saved successfully.' + if len( sample_datasets ) == len( incorrect_dataset_names ): + status = 'error' + message = 'All datasets renamed incorrectly.' + elif len( incorrect_dataset_names ): + status = 'done' + message = 'Changes saved successfully. The following datasets were renamed incorrectly: %s.' % str( incorrect_dataset_names ) + else: + message = 'Changes saved successfully.' return trans.fill_template( '/admin/requests/rename_datasets.mako', sample=sample, id_list=id_list, --- a/test/base/twilltestcase.py +++ b/test/base/twilltestcase.py @@ -1638,6 +1638,23 @@ class TwillTestCase( unittest.TestCase ) tc.submit( "save_samples_button" ) for check_str in strings_displayed_after_submit: self.check_page_for_string( check_str ) + def change_sample_target_data_library( self, cntrller, request_id, sample_ids, new_library_id, new_folder_id, comment='', strings_displayed=[], strings_displayed_after_submit=[] ): + url = "%s/requests_common/edit_samples?cntrller=%s&id=%s&editing_samples=True" % ( self.url, cntrller, request_id ) + self.visit_url( url ) + for check_str in strings_displayed: + self.check_page_for_string( check_str ) + for sample_id in sample_ids: + tc.fv( "1", "select_sample_%i" % sample_id, True ) + tc.fv( "1", "sample_operation", 'Select data library and folder' ) + self.refresh_form( "sample_operation", 'Select data library and folder' ) + self.check_page_for_string( "Select data library:" ) + tc.fv( "1", "sample_0_library_id", new_library_id ) + self.refresh_form( "sample_0_library_id", new_library_id ) + self.check_page_for_string( "Select folder:" ) + tc.fv( "1", "sample_0_folder_id", new_folder_id ) + tc.submit( "save_samples_button" ) + for check_str in strings_displayed_after_submit: + self.check_page_for_string( check_str ) def add_user_address( self, user_id, address_dict ): self.home() self.visit_url( "%s/user/new_address?admin_view=False&user_id=%i" % ( self.url, user_id ) ) --- a/lib/galaxy/web/controllers/forms.py +++ b/lib/galaxy/web/controllers/forms.py @@ -635,8 +635,8 @@ class Forms( BaseController ): if form_type == trans.model.FormDefinition.types.SAMPLE: for ft in trans.model.Sample.supported_field_types: if ft.__name__ == field[ 'type' ]: - self.fieldtype.add_option( ft.__name__, ft__name__, selected=True ) - if ft == 'SelectField': + self.fieldtype.add_option( ft.__name__, ft.__name__, selected=True ) + if ft.__name__ == 'SelectField': self.selectbox_ui( field ) else: self.fieldtype.add_option( ft.__name__, ft.__name__ ) @@ -644,7 +644,7 @@ class Forms( BaseController ): for ft in trans.model.FormDefinition.supported_field_types: if ft.__name__ == field[ 'type' ]: self.fieldtype.add_option( ft.__name__, ft.__name__, selected=True ) - if ft == 'SelectField': + if ft.__name__ == 'SelectField': self.selectbox_ui( field ) else: self.fieldtype.add_option( ft.__name__, ft.__name__ )
participants (1)
-
commits-noreply@bitbucket.org