# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User rc # Date 1289841695 18000 # Node ID efc0b15af4026aa039945c799354e8cac5975528 # Parent bde1ca8b6134079a9323d76bcaf057b3cc4166c1 More tests added to sample tracking functional tests --- a/test/functional/test_sample_tracking.py +++ b/test/functional/test_sample_tracking.py @@ -360,10 +360,13 @@ class TestFormsAndRequests( TwillTestCas strings_displayed=[ 'Edit sequencing request "%s"' % request1.name ], strings_displayed_after_submit=[ new_name, new_desc ] ) refresh( request1 ) - # now check email notification settings - check_sample_states = [ ( request1.type.states[0].name, request1.type.states[0].id, True ), - ( request1.type.states[2].name, request1.type.states[2].id, True ), - ( request1.type.states[4].name, request1.type.states[4].id, True ) ]#[ ( state.id, True ) for state in request1.type.states ] + # define the sample states when we want an email notification + global email_notification_sample_states + email_notification_sample_states = [ request1.type.states[2], request1.type.states[4] ] + # check email notification settings + check_sample_states = [] + for state in email_notification_sample_states: + check_sample_states.append( ( state.name, state.id, True ) ) strings_displayed = [ 'Edit sequencing request "%s"' % request1.name, 'Email notification settings' ] additional_emails = [ 'test@.bx.psu.edu', 'test2@.bx.psu.edu' ] @@ -496,7 +499,9 @@ class TestFormsAndRequests( TwillTestCas # def test_050_receive_request_as_admin( self ): """Testing receiving a sequencing request and assigning it barcodes""" + # logged in as regular_user1 self.logout() + # login as a admin_user to assign bar codes to samples self.login( email=admin_user.email ) self.check_request_grid( cntrller='requests_admin', state=request1.states.SUBMITTED, @@ -540,49 +545,48 @@ class TestFormsAndRequests( TwillTestCas sample_id=self.security.encode_id( sample.id ), strings_displayed=strings_displayed, strings_not_displayed=strings_not_displayed ) -# def test_040_request_lifecycle( self ): -# """Testing request life-cycle as it goes through all the states""" -# # logged in as regular_user1 -# self.logout() -# self.login( email=admin_user.email ) -# self.check_request_grid( cntrller='requests_admin', -# state=request1.states.SUBMITTED, -# strings_displayed=[ request1.name ] ) -# self.visit_url( "%s/requests_common/view_request?cntrller=requests&id=%s" % ( self.url, self.security.encode_id( request1.id ) ) ) -# # TODO: add some string for checking on the page above... -# # Set bar codes for the samples -# bar_codes = [ '1234567890', '0987654321' ] -# strings_displayed_after_submit=[ 'Changes made to the samples have been saved.' ] -# for bar_code in bar_codes: -# strings_displayed_after_submit.append( bar_code ) -# self.add_bar_codes( request_id=self.security.encode_id( request1.id ), -# request_name=request1.name, -# bar_codes=bar_codes, -# samples=request1.samples, -# strings_displayed_after_submit=strings_displayed_after_submit ) -# # Change the states of all the samples of this request to ultimately be COMPLETE -# self.change_sample_state( request_id=self.security.encode_id( request1.id ), -# request_name=request1.name, -# sample_names=[ sample.name for sample in request1.samples ], -# sample_ids=[ sample.id for sample in request1.samples ], -# new_sample_state_id=request_type1.states[1].id, -# new_state_name=request_type1.states[1].name ) -# self.change_sample_state( request_id=self.security.encode_id( request1.id ), -# request_name=request1.name, -# sample_names=[ sample.name for sample in request1.samples ], -# sample_ids=[ sample.id for sample in request1.samples ], -# new_sample_state_id=request_type1.states[2].id, -# new_state_name=request_type1.states[2].name ) -# refresh( request1 ) -# self.logout() -# self.login( email=regular_user1.email ) -# # check if the request's state is now set to 'complete' -# self.check_request_grid( cntrller='requests', -# state='Complete', -# strings_displayed=[ request1.name ] ) -# assert request1.state is not request1.states.COMPLETE, "The state of the request '%s' should be set to '%s'" \ -# % ( request1.name, request1.states.COMPLETE ) -# + def test_055_request_lifecycle( self ): + """Testing request life-cycle as it goes through all the states""" + # logged in as admin_user + self.check_request_grid( cntrller='requests_admin', + state=request1.states.SUBMITTED, + strings_displayed=[ request1.name ] ) + strings_displayed=[ 'History of sequencing request "%s"' % request1.name ] + # Change the states of all the samples of this request to ultimately be COMPLETE + for index, state in enumerate( request_type1.states ): + # start from the second state onwards + if index > 1: + # status message + if index == len( request_type1.states ) - 1: + status_msg = 'All samples of this request are in the final sample state (%s).' % state.name + else: + status_msg = 'All samples of this request are in the (%s) sample state. ' % state.name + # check email notification message + email_msg = '' + if state.id in [ email_state.id for email_state in email_notification_sample_states ]: + email_msg = 'Email notification failed as SMTP server not set in config file' + self.change_sample_state( request_id=self.security.encode_id( request1.id ), + sample_ids=[ sample.id for sample in request1.samples ], + new_sample_state_id=self.security.encode_id( state.id ), + strings_displayed=[ 'Edit Current Samples of Request "%s"' % request1.name ], + strings_displayed_after_submit = [ status_msg, email_msg ] ) + # check request history page + if index == len( request_type1.states ) - 1: + strings_displayed.append( status_msg ) + else: + strings_displayed.append( status_msg ) + self.view_request_history( cntrller='requests_admin', + request_id=self.security.encode_id( request1.id ), + strings_displayed=strings_displayed, + strings_not_displayed=[ request1.states.REJECTED ] ) + refresh( request1 ) + # check if the request's state is now set to 'complete' + self.check_request_grid( cntrller='requests_admin', + state='Complete', + strings_displayed=[ request1.name ] ) + assert request1.state is not request1.states.COMPLETE, "The state of the request '%s' should be set to '%s'" \ + % ( request1.name, request1.states.COMPLETE ) + # def test_045_admin_create_request_on_behalf_of_regular_user( self ): # """Testing creating and submitting a request as an admin on behalf of a regular user""" # # Logged in as regular_user1 @@ -660,7 +664,7 @@ class TestFormsAndRequests( TwillTestCas # # Make sure the request's state is now set to REJECTED # assert request2.state is not request2.states.REJECTED, "The state of the request '%s' should be set to '%s'" \ # % ( request2.name, request2.states.REJECTED ) - def test_055_reset_data_for_later_test_runs( self ): + def __test_055_reset_data_for_later_test_runs( self ): """Reseting data to enable later test runs to pass""" # Logged in as admin_user self.logout() --- a/test/base/twilltestcase.py +++ b/test/base/twilltestcase.py @@ -1434,9 +1434,9 @@ class TwillTestCase( unittest.TestCase ) '''View form details''' self.home() self.visit_url( "%s/forms/manage?operation=view&id=%s" % ( self.url, id ) ) - self.check_page_for_string( form_type ) + #self.check_page_for_string( form_type ) self.check_page_for_string( form_name ) - self.check_page_for_string( form_desc ) + #self.check_page_for_string( form_desc ) self.check_page_for_string( form_layout_name ) for i, field_dict in enumerate( field_dicts ): self.check_page_for_string( field_dict[ 'name' ] ) @@ -1495,8 +1495,7 @@ class TwillTestCase( unittest.TestCase ) '''View request_type details''' self.home() self.visit_url( "%s/requests_admin/view_request_type?id=%s" % ( self.url, request_type_id ) ) - self.check_page_for_string( 'Sequencer configuration information' ) - self.check_page_for_string( request_type_name ) + self.check_page_for_string( '"%s" sequencer configuration' % request_type_name ) for name, desc in sample_states: self.check_page_for_string( name ) self.check_page_for_string( desc ) @@ -1624,23 +1623,21 @@ class TwillTestCase( unittest.TestCase ) tc.submit( "reject_button" ) for check_str in strings_displayed_after_submit: self.check_page_for_string( check_str ) - def change_sample_state( self, request_id, request_name, sample_names, sample_ids, new_sample_state_id, new_state_name, comment='', - strings_displayed=[], strings_displayed_after_submit=[] ): - # We have to simulate the form submission here since twill barfs on the page - # gvk - 9/22/10 - TODO: make sure the mako template produces valid html - url = "%s/requests_common/edit_samples?cntrller=requests_admin&id=%s" % ( self.url, request_id ) - url += "&comment=%s&sample_state_id=%s" % ( comment, self.security.encode_id( new_sample_state_id ) ) - # select_sample_%i=true must be included twice for each sample to simulate a CheckboxField checked setting. + def change_sample_state( self, request_id, sample_ids, new_sample_state_id, comment='', strings_displayed=[], strings_displayed_after_submit=[] ): + url = "%s/requests_common/edit_samples?cntrller=requests_admin&id=%s&editing_samples=True" % ( self.url, 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: - url += "&select_sample_%i=true&select_sample_%i=true" % ( sample_id, sample_id ) - url += "&sample_operation=Change%20state&refresh=true" - url += "&save_changes_button=Save&editing_samples=True" - self.visit_url( url ) - self.check_page_for_string( 'Edit Current Samples of Request "%s"' % request_name ) - for sample_id, sample_name in zip( sample_ids, sample_names ): - self.visit_url( "%s/requests_common/sample_events?cntrller=requests_admin&sample_id=%s" % ( self.url, self.security.encode_id( sample_id ) ) ) - self.check_page_for_string( 'Events for Sample "%s"' % sample_name ) - self.check_page_for_string( new_state_name ) + tc.fv( "1", "select_sample_%i" % sample_id, True ) + tc.fv( "1", "sample_operation", 'Change state' ) + self.refresh_form( "sample_operation", 'Change state' ) + self.check_page_for_string( "Change current state" ) + tc.fv( "1", "sample_state_id", new_sample_state_id ) + tc.fv( "1", "sample_event_comment", comment ) + 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/templates/requests/common/edit_samples.mako +++ b/templates/requests/common/edit_samples.mako @@ -137,7 +137,8 @@ <p/><div class="form-row"> ## hidden element to make twill work. - <input type="hidden" name="hidden_input" value=""/> + ## Greg will fix this + <input type="hidden" name="twill" value=""/> %if ( request.samples or displayable_sample_widgets ) and ( editing_samples or len( displayable_sample_widgets ) > len( request.samples ) ): <input type="submit" name="add_sample_button" value="Add sample" /><input type="submit" name="save_samples_button" value="Save"/> @@ -156,7 +157,8 @@ <p/><div class="form-row"> ## hidden element to make twill work. - <input type="hidden" name="hidden_input" value=""/> + ## Greg will fix this + <input type="hidden" name="twill" value=""/><input type="submit" name="save_samples_button" value="Save"/><input type="submit" name="cancel_changes_button" value="Cancel"/><div class="toolParamHelp" style="clear: both;"> --- a/lib/galaxy/web/controllers/forms.py +++ b/lib/galaxy/web/controllers/forms.py @@ -420,7 +420,7 @@ class Forms( BaseController ): 'visible': True, 'required': required, 'type': field_type, - 'selectlist': selectlist, + 'selectlist': options, 'layout': layout, 'default': default } return { 'label': name,