def test_040_sharing_mulitple_histories_with_multiple_users(self): """Testing sharing multiple histories containing only public datasets with multiple users""" # Logged in as admin_user self.new_history() global history4 history4 = ( sa_session.query(galaxy.model.History) .filter( and_( galaxy.model.History.table.c.deleted == False, galaxy.model.History.table.c.user_id == admin_user.id ) ) .order_by(desc(galaxy.model.History.table.c.create_time)) .first() ) assert history4 is not None, "Problem retrieving history4 from database" self.rename_history(self.security.encode_id(history4.id), history4.name, new_name=urllib.quote("history 4")) sa_session.refresh(history4) self.upload_file("2.bed", dbkey="hg18") ids = "%s,%s" % (self.security.encode_id(history3.id), self.security.encode_id(history4.id)) 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) 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.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)
def test_085_reset_data_for_later_test_runs(self): """Reseting data to enable later test runs to to be valid""" # logged in as admin_user # Clean up admin_user # Unshare history3 - shared with regular_user1, regular_user2, regular_user3 self.unshare_history(self.security.encode_id(history3.id), self.security.encode_id(regular_user1.id)) self.unshare_history(self.security.encode_id(history3.id), self.security.encode_id(regular_user2.id)) self.unshare_history(self.security.encode_id(history3.id), self.security.encode_id(regular_user3.id)) # Unshare history4 - shared with regular_user2, regular_user3 self.unshare_history(self.security.encode_id(history4.id), self.security.encode_id(regular_user2.id)) self.unshare_history(self.security.encode_id(history4.id), self.security.encode_id(regular_user3.id)) # Unshare history5 - shared with regular_user1 self.unshare_history(self.security.encode_id(history5.id), self.security.encode_id(regular_user1.id)) # Delete histories self.delete_history(id=self.security.encode_id(history3.id)) self.delete_history(id=self.security.encode_id(history3_clone2.id)) self.delete_history(id=self.security.encode_id(history3_clone3.id)) self.delete_history(id=self.security.encode_id(history4.id)) self.delete_history(id=self.security.encode_id(history5.id)) # Eliminate Sharing role for: [email protected], [email protected] self.mark_role_deleted(self.security.encode_id(sharing_role.id), sharing_role.name) self.purge_role(self.security.encode_id(sharing_role.id), sharing_role.name) # Manually delete the sharing role from the database sa_session.refresh(sharing_role) sa_session.delete(sharing_role) sa_session.flush() # Clean up regular_user_1 self.logout() self.login(email=regular_user1.email) self.delete_history(id=self.security.encode_id(history3_clone1.id)) self.delete_history(id=self.security.encode_id(history5_clone1.id))
def test_035_request_lifecycle(self): """Testing request lifecycle as it goes through all the states""" # goto admin manage requests page self.logout() self.login(email='*****@*****.**') self.check_request_admin_grid(state='Submitted', request_name=request_one.name) self.visit_url( "%s/requests_admin/list?sort=-create_time&operation=show_request&id=%s" \ % ( self.url, self.security.encode_id( request_one.id ) )) self.check_page_for_string('Sequencing Request "%s"' % request_one.name) # set bar codes for the samples bar_codes = ['1234567890', '0987654321'] self.add_bar_codes(request_one.id, request_one.name, bar_codes) # change the states of all the samples of this request for sample in request_one.samples: self.change_sample_state(sample.name, sample.id, request_type.states[1].id, request_type.states[1].name) self.change_sample_state(sample.name, sample.id, request_type.states[2].id, request_type.states[2].name) self.home() sa_session.refresh(request_one) self.logout() self.login(email='*****@*****.**') # check if the request's state is now set to 'complete' self.check_request_grid(state='Complete', request_name=request_one.name) assert request_one.state is not request_one.states.COMPLETE, "The state of the request '%s' should be set to '%s'" \ % ( request_one.name, request_one.states.COMPLETE )
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
def get_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 fdc.latest_form.name == name: return fdc.latest_form return None
def test_045_reject_request( self ): '''Testing rejecting a request''' self.logout() self.login( email='*****@*****.**' ) self.reject_request( request_two.id, request_two.name, "Rejection test comment" ) sa_session.refresh( request_two ) # check if the request is showing in the 'rejected' filter self.check_request_admin_grid(state='Rejected', request_name=request_two.name) # check if the request's state is now set to 'submitted' assert request_two.state is not request_two.states.REJECTED, "The state of the request '%s' should be set to '%s'" \ % ( request_two.name, request_two.states.REJECTED )
def test_00_metadata_edit(self): """test_metadata_edit: Testing metadata editing""" self.logout() self.login(email='*****@*****.**', username='******') admin_user = sa_session.query( galaxy.model.User ) \ .filter( galaxy.model.User.table.c.email=='*****@*****.**' ) \ .one() self.new_history(name='Test Metadata Edit') history1 = sa_session.query( galaxy.model.History ) \ .filter( and_( galaxy.model.History.table.c.deleted==False, galaxy.model.History.table.c.user_id==admin_user.id ) ) \ .order_by( desc( galaxy.model.History.table.c.create_time ) ) \ .first() self.upload_file('1.bed') latest_hda = sa_session.query( galaxy.model.HistoryDatasetAssociation ) \ .order_by( desc( galaxy.model.HistoryDatasetAssociation.table.c.create_time ) ) \ .first() self.home() # Due to twill not being able to handle the permissions forms, we'll eliminate # DefaultHistoryPermissions prior to uploading a dataset so that the permission # form will not be displayed on ted edit attributes page. for dp in latest_hda.dataset.actions: sa_session.delete(dp) sa_session.flush() sa_session.refresh(latest_hda.dataset) self.check_history_for_string('1.bed') self.check_metadata_for_string( '1.bed uploaded file unspecified (\?) chromCol value="1" selected endCol value="3" is_strandCol value="true" checked', hid=str(latest_hda.hid)) """test editing attributes""" self.edit_hda_attribute_info(hda_id=str(latest_hda.id), new_name='Testdata', new_info="Uploaded my file", new_dbkey='hg16', new_startcol='6') self.check_metadata_for_string( 'Testdata bed Uploaded my file hg16 "bed" selected="yes" "startCol" value="6" selected', hid=str(latest_hda.hid)) """test Auto-detecting attributes""" self.auto_detect_metadata(hda_id=str(latest_hda.id)) self.check_metadata_for_string( 'Testdata bed Uploaded my file hg16 "bed" selected="yes" "startCol" value="2" selected', hid=str(latest_hda.hid)) """test converting formats""" self.convert_format(hda_id=str(latest_hda.id), target_type='gff') self.check_metadata_for_string('"gff" selected="yes"', hid=str(latest_hda.hid)) """test changing data type""" self.change_datatype(hda_id=str(latest_hda.id), datatype='gff3') self.check_metadata_for_string('gff3', hid=str(latest_hda.hid)) self.delete_history(id=self.security.encode_id(history1.id)) self.logout()
def test_045_reject_request(self): '''Testing rejecting a request''' self.logout() self.login(email='*****@*****.**') self.reject_request(request_two.id, request_two.name, "Rejection test comment") sa_session.refresh(request_two) # check if the request is showing in the 'rejected' filter self.check_request_admin_grid(state='Rejected', request_name=request_two.name) # check if the request's state is now set to 'submitted' assert request_two.state is not request_two.states.REJECTED, "The state of the request '%s' should be set to '%s'" \ % ( request_two.name, request_two.states.REJECTED )
def test_020_share_current_history(self): """Testing sharing the current history which contains only public datasets""" # 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." ) # 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." ) # Share history3 with 1 valid user self.share_current_history(regular_user1.email, check_str=history3.name) # Check out list of histories to make sure history3 was shared self.view_stored_active_histories(check_str="operation=sharing") # Enable importing history3 via a URL self.enable_import_via_link( self.security.encode_id(history3.id), check_str="Unshare", check_str_after_submit="Send the above link to users", ) # Make sure history3 is now import-able sa_session.refresh(history3) if not history3.importable: raise AssertionError, "History 3 is not marked as importable after enable_import_via_link" # 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.", ) # Disable the import link for history3 self.disable_import_via_link( self.security.encode_id(history3.id), check_str="Send the above link to users", check_str_after_submit="Enable import via link", ) # Try importing history3 after disabling the URL self.import_history_via_url( self.security.encode_id(history3.id), admin_user.email, check_str_after_submit="The owner of this history has disabled imports via this link.", ) # Test sharing history3 with an invalid user self.share_current_history("*****@*****.**", check_str_after_submit="[email protected] is not a valid Galaxy user.")
def test_010_history_rename(self): """Testing renaming a history""" # Logged in as admin_user global history3 history3 = ( sa_session.query(galaxy.model.History) .filter(galaxy.model.History.table.c.deleted == False) .order_by(desc(galaxy.model.History.table.c.create_time)) .first() ) assert history3 is not None, "Problem retrieving history3 from database" if history3.deleted: raise AssertionError, "History id %d deleted when it should not be" % latest_history.id self.rename_history(self.security.encode_id(history3.id), history3.name, new_name=urllib.quote("history 3")) sa_session.refresh(history3)
def test_030_create_request(self): """Testing creating, editing and submitting a request as a regular user""" # login as a regular user self.logout() self.login(email='*****@*****.**') # set field values fields = ['option1', str(user_address.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, library_one.id, 'none', 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() # 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 ) # sample fields samples = [('Sample One', ['S1 Field 0 Value']), ('Sample Two', ['S2 Field 0 Value'])] # 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)' ] self.edit_request(request_one.id, request_one.name, request_one.name + ' (Renamed)', request_one.desc + ' (Re-described)', library_one.id, folder_one.id, fields) sa_session.refresh(request_one) # check if the request is showing in the 'new' filter self.check_request_grid(state='New', request_name=request_one.name) # submit the request self.submit_request(request_one.id, request_one.name) sa_session.refresh(request_one) # check if the request is showing in the 'submitted' filter self.check_request_grid(state='Submitted', request_name=request_one.name) # check if the request's state is now set to 'submitted' assert request_one.state is not request_one.states.SUBMITTED, "The state of the request '%s' should be set to '%s'" \ % ( request_one.name, request_one.states.SUBMITTED )
def test_00_metadata_edit( self ): """test_metadata_edit: Testing metadata editing""" self.logout() self.login( email='*****@*****.**' ) admin_user = sa_session.query( galaxy.model.User ) \ .filter( galaxy.model.User.table.c.email=='*****@*****.**' ) \ .one() self.new_history( name='Test Metadata Edit' ) history1 = sa_session.query( galaxy.model.History ) \ .filter( and_( galaxy.model.History.table.c.deleted==False, galaxy.model.History.table.c.user_id==admin_user.id ) ) \ .order_by( desc( galaxy.model.History.table.c.create_time ) ) \ .first() self.upload_file( '1.bed' ) latest_hda = sa_session.query( galaxy.model.HistoryDatasetAssociation ) \ .order_by( desc( galaxy.model.HistoryDatasetAssociation.table.c.create_time ) ) \ .first() self.home() # Due to twill not being able to handle the permissions forms, we'll eliminate # DefaultHistoryPermissions prior to uploading a dataset so that the permission # form will not be displayed on ted edit attributes page. for dp in latest_hda.dataset.actions: sa_session.delete( dp ) sa_session.flush() sa_session.refresh( latest_hda.dataset ) self.check_history_for_string( '1.bed' ) self.check_metadata_for_string( '1.bed uploaded file unspecified (\?) chromCol value="1" selected endCol value="3" is_strandCol value="true" checked', hid=str( latest_hda.hid ) ) """test editing attributes""" self.edit_hda_attribute_info( hda_id=str( latest_hda.id ), new_name='Testdata', new_info="Uploaded my file", new_dbkey='hg16', new_startcol='6' ) self.check_metadata_for_string( 'Testdata bed Uploaded my file hg16 "bed" selected="yes" "startCol" value="6" selected', hid=str( latest_hda.hid ) ) """test Auto-detecting attributes""" self.auto_detect_metadata( hda_id=str( latest_hda.id ) ) self.check_metadata_for_string('Testdata bed Uploaded my file hg16 "bed" selected="yes" "startCol" value="2" selected', hid=str( latest_hda.hid ) ) """test converting formats""" self.convert_format( hda_id=str( latest_hda.id ), target_type='gff' ) self.check_metadata_for_string( '"gff" selected="yes"', hid=str( latest_hda.hid ) ) """test changing data type""" self.change_datatype( hda_id=str( latest_hda.id ), datatype='gff3' ) self.check_metadata_for_string( 'gff3', hid=str( latest_hda.hid ) ) self.delete_history( id=self.security.encode_id( history1.id ) ) self.logout()
def test_040_admin_create_request_on_behalf_of_regular_user(self): """Testing creating and submitting a request as an admin on behalf of a regular user""" self.logout() self.login(email='*****@*****.**') request_name = "RequestTwo" # simulate request creation url_str = '%s/requests_admin/new?create=True&create_request_button=Save&select_request_type=%i&select_user=%i&name=%s&library_id=%i&folder_id=%i&refresh=True&field_2=%s&field_0=%s&field_1=%i' \ % ( self.url, request_type.id, regular_user.id, request_name, library_one.id, library_one.root_folder.id, "field_2_value", 'option1', user_address.id ) self.home() self.visit_url(url_str) self.check_page_for_string( "The new request named %s has been created" % request_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() # check if the request is showing in the 'new' filter self.check_request_admin_grid(state='New', request_name=request_two.name) # check if the request's state is now set to 'new' assert request_two.state is not request_two.states.NEW, "The state of the request '%s' should be set to '%s'" \ % ( request_two.name, request_two.states.NEW ) # sample fields samples = [('Sample One', ['S1 Field 0 Value']), ('Sample Two', ['S2 Field 0 Value'])] # add samples to this request 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) # check if the request is showing in the 'submitted' filter self.check_request_admin_grid(state='Submitted', request_name=request_two.name) # check if the request's state is now set to 'submitted' assert request_two.state is not request_two.states.SUBMITTED, "The state of the request '%s' should be set to '%s'" \ % ( request_two.name, request_two.states.SUBMITTED ) # check if both the requests is showing in the 'All' filter self.check_request_admin_grid(state='All', request_name=request_one.name) self.check_request_admin_grid(state='All', request_name=request_two.name)
def test_045_change_permissions_on_current_history(self): """Testing changing permissions on the current history""" # Logged in as regular_user3 self.logout() self.login(email=admin_user.email) # Current history is history4 self.new_history() global history5 history5 = ( sa_session.query(galaxy.model.History) .filter( and_( galaxy.model.History.table.c.deleted == False, galaxy.model.History.table.c.user_id == admin_user.id ) ) .order_by(desc(galaxy.model.History.table.c.create_time)) .first() ) assert history5 is not None, "Problem retrieving history5 from database" self.rename_history(self.security.encode_id(history5.id), history5.name, new_name=urllib.quote("history 5")) # Current history is hostory5 sa_session.refresh(history5) # Due to the limitations of twill ( not functional with the permissions forms ), we're forced # to do this manually. At this point, we just want to restrict the access permission on history5 # to the admin_user global access_action access_action = galaxy.model.Dataset.permitted_actions.DATASET_ACCESS.action dhp = galaxy.model.DefaultHistoryPermissions(history5, access_action, admin_user_private_role) sa_session.add(dhp) sa_session.flush() sa_session.refresh(history5) global history5_default_permissions history5_default_permissions = [dhp.action for dhp in history5.default_permissions] # Sort for later comparison history5_default_permissions.sort() self.upload_file("1.bed", dbkey="hg18") history5_dataset1 = None for hda in history5.datasets: if hda.name == "1.bed": history5_dataset1 = hda.dataset break assert history5_dataset1 is not None, "Problem retrieving history5_dataset1 from the database" # The permissions on the dataset should be restricted from sharing with anyone due to the # inherited history permissions dataset_permissions = [a.action for a in history5_dataset1.actions] dataset_permissions.sort() if dataset_permissions != history5_default_permissions: err_msg = ( "Dataset permissions for history5_dataset1 (%s) were not correctly inherited from history permissions (%s)" % (str(dataset_permissions), str(history5_default_permissions)) ) raise AssertionError, err_msg # Make sure when we logout and login, the history default permissions are preserved self.logout() self.login(email=admin_user.email) sa_session.refresh(history5) current_history_permissions = [dhp.action for dhp in history5.default_permissions] current_history_permissions.sort() if current_history_permissions != history5_default_permissions: raise AssertionError, "With logout and login, the history default permissions are not preserved"
def test_030_create_request( self ): """Testing creating, editing and submitting a request as a regular user""" # login as a regular user self.logout() self.login( email='*****@*****.**' ) # set field values fields = ['option1', str(user_address.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, library_one.id, 'none', 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() # 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 ) # sample fields samples = [ ( 'Sample One', [ 'S1 Field 0 Value' ] ), ( 'Sample Two', [ 'S2 Field 0 Value' ] ) ] # 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)'] self.edit_request(request_one.id, request_one.name, request_one.name+' (Renamed)', request_one.desc+' (Re-described)', library_one.id, folder_one.id, fields) sa_session.refresh( request_one ) # check if the request is showing in the 'new' filter self.check_request_grid(state='New', request_name=request_one.name) # submit the request self.submit_request( request_one.id, request_one.name ) sa_session.refresh( request_one ) # check if the request is showing in the 'submitted' filter self.check_request_grid(state='Submitted', request_name=request_one.name) # check if the request's state is now set to 'submitted' assert request_one.state is not request_one.states.SUBMITTED, "The state of the request '%s' should be set to '%s'" \ % ( request_one.name, request_one.states.SUBMITTED )
def test_040_admin_create_request_on_behalf_of_regular_user( self ): """Testing creating and submitting a request as an admin on behalf of a regular user""" self.logout() self.login( email='*****@*****.**' ) request_name = "RequestTwo" # simulate request creation url_str = '%s/requests_admin/new?create=True&create_request_button=Save&select_request_type=%i&select_user=%i&name=%s&library_id=%i&folder_id=%i&refresh=True&field_2=%s&field_0=%s&field_1=%i' \ % ( self.url, request_type.id, regular_user.id, request_name, library_one.id, library_one.root_folder.id, "field_2_value", 'option1', user_address.id ) self.home() self.visit_url( url_str ) self.check_page_for_string( "The new request named %s has been created" % request_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() # check if the request is showing in the 'new' filter self.check_request_admin_grid(state='New', request_name=request_two.name) # check if the request's state is now set to 'new' assert request_two.state is not request_two.states.NEW, "The state of the request '%s' should be set to '%s'" \ % ( request_two.name, request_two.states.NEW ) # sample fields samples = [ ( 'Sample One', [ 'S1 Field 0 Value' ] ), ( 'Sample Two', [ 'S2 Field 0 Value' ] ) ] # add samples to this request 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 ) # check if the request is showing in the 'submitted' filter self.check_request_admin_grid(state='Submitted', request_name=request_two.name) # check if the request's state is now set to 'submitted' assert request_two.state is not request_two.states.SUBMITTED, "The state of the request '%s' should be set to '%s'" \ % ( request_two.name, request_two.states.SUBMITTED ) # check if both the requests is showing in the 'All' filter self.check_request_admin_grid(state='All', request_name=request_one.name) self.check_request_admin_grid(state='All', request_name=request_two.name)
def test_035_request_lifecycle( self ): """Testing request lifecycle as it goes through all the states""" # goto admin manage requests page self.logout() self.login( email='*****@*****.**' ) self.check_request_admin_grid(state='Submitted', request_name=request_one.name) self.visit_url( "%s/requests_admin/list?sort=-create_time&operation=show_request&id=%s" \ % ( self.url, self.security.encode_id( request_one.id ) )) self.check_page_for_string( 'Sequencing Request "%s"' % request_one.name ) # set bar codes for the samples bar_codes = [ '1234567890', '0987654321' ] self.add_bar_codes( request_one.id, request_one.name, bar_codes ) # change the states of all the samples of this request for sample in request_one.samples: self.change_sample_state( sample.name, sample.id, request_type.states[1].id, request_type.states[1].name ) self.change_sample_state( sample.name, sample.id, request_type.states[2].id, request_type.states[2].name ) self.home() sa_session.refresh( request_one ) self.logout() self.login( email='*****@*****.**' ) # check if the request's state is now set to 'complete' self.check_request_grid(state='Complete', request_name=request_one.name) assert request_one.state is not request_one.states.COMPLETE, "The state of the request '%s' should be set to '%s'" \ % ( request_one.name, request_one.states.COMPLETE )
def test_080_copying_history_items_between_histories(self): """Testing copying history items between histories""" # logged in as admin_user self.new_history(name=urllib.quote("copy history items")) history6 = ( sa_session.query(galaxy.model.History) .filter( and_( galaxy.model.History.table.c.deleted == False, galaxy.model.History.table.c.user_id == admin_user.id ) ) .order_by(desc(galaxy.model.History.table.c.create_time)) .first() ) assert history6 is not None, "Problem retrieving history6 from database" self.upload_file("1.bed", dbkey="hg18") hda1 = ( sa_session.query(galaxy.model.HistoryDatasetAssociation) .order_by(desc(galaxy.model.HistoryDatasetAssociation.table.c.create_time)) .first() ) assert hda1 is not None, "Problem retrieving hda1 from database" # We'll just test copying 1 hda source_dataset_ids = str(hda1.id) # The valid list of target histories is only the user's active histories all_target_history_ids = [str(hda.id) for hda in admin_user.active_histories] # Since history1 and history2 have been deleted, they should not be displayed in the list of target histories # on the copy_view.mako form deleted_history_ids = [str(history1.id), str(history2.id)] # Test copying to the current history target_history_ids = [str(history6.id)] self.copy_history_item( source_dataset_ids=source_dataset_ids, target_history_ids=target_history_ids, all_target_history_ids=all_target_history_ids, deleted_history_ids=deleted_history_ids, ) sa_session.refresh(history6) if len(history6.datasets) != 2: raise AssertionError, "Copying hda1 to the current history failed, history 6 has %d datasets, but should have 2" % len( history6.datasets ) # Test copying 1 hda to another history self.new_history(name=urllib.quote("copy history items - 2")) history7 = ( sa_session.query(galaxy.model.History) .filter( and_( galaxy.model.History.table.c.deleted == False, galaxy.model.History.table.c.user_id == admin_user.id ) ) .order_by(desc(galaxy.model.History.table.c.create_time)) .first() ) assert history7 is not None, "Problem retrieving history7 from database" # Switch back to our history from which we want to copy self.switch_history(id=self.security.encode_id(history6.id), name=history6.name) target_history_ids = [str(history7.id)] all_target_history_ids = [str(hda.id) for hda in admin_user.active_histories] # Test copying to the a history that is not the current history target_history_ids = [str(history7.id)] self.copy_history_item( source_dataset_ids=source_dataset_ids, target_history_ids=target_history_ids, all_target_history_ids=all_target_history_ids, deleted_history_ids=deleted_history_ids, ) # Switch to the history to which we copied self.switch_history(id=self.security.encode_id(history7.id), name=history7.name) self.check_history_for_string(hda1.name) self.delete_history(self.security.encode_id(history6.id)) self.delete_history(self.security.encode_id(history7.id))
def refresh( obj ): sa_session.refresh( obj )
def test_005_deleting_histories(self): """Testing deleting histories""" # Logged in as admin_user historyB = ( sa_session.query(galaxy.model.History) .filter( and_( galaxy.model.History.table.c.deleted == False, galaxy.model.History.table.c.user_id == admin_user.id ) ) .order_by(desc(galaxy.model.History.table.c.create_time)) .first() ) assert historyB is not None, "Problem retrieving historyB from database" self.delete_history(self.security.encode_id(historyB.id)) sa_session.refresh(historyB) if not historyB.deleted: raise AssertionError, "Problem deleting history id %d" % historyB.id # Since we deleted the current history, make sure the history frame was refreshed self.check_history_for_string("Your history is empty.") # We'll now test deleting a list of histories # After deleting the current history, a new one should have been created global history1 history1 = ( sa_session.query(galaxy.model.History) .filter( and_( galaxy.model.History.table.c.deleted == False, galaxy.model.History.table.c.user_id == admin_user.id ) ) .order_by(desc(galaxy.model.History.table.c.create_time)) .first() ) assert history1 is not None, "Problem retrieving history1 from database" self.upload_file("1.bed", dbkey="hg18") self.new_history(name=urllib.quote("history2")) global history2 history2 = ( sa_session.query(galaxy.model.History) .filter( and_( galaxy.model.History.table.c.deleted == False, galaxy.model.History.table.c.user_id == admin_user.id ) ) .order_by(desc(galaxy.model.History.table.c.create_time)) .first() ) assert history2 is not None, "Problem retrieving history2 from database" self.upload_file("2.bed", dbkey="hg18") ids = "%s,%s" % (self.security.encode_id(history1.id), self.security.encode_id(history2.id)) self.delete_history(ids) # 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) 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) try: self.view_stored_active_histories(check_str=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) sa_session.refresh(history1) if not history1.deleted: raise AssertionError, "Problem deleting history id %d" % history1.id if not history1.default_permissions: raise AssertionError, "Default permissions were incorrectly deleted from the db for history id %d when it was deleted" % history1.id sa_session.refresh(history2) if not history2.deleted: raise AssertionError, "Problem deleting history id %d" % history2.id if not history2.default_permissions: raise AssertionError, "Default permissions were incorrectly deleted from the db for history id %d when it was deleted" % history2.id # Current history is empty self.history_options(user=True)
def ga_refresh( obj ): ga_session.refresh( obj )
def refresh(obj): sa_session.refresh(obj)
def test_get_DNAseHSS_flanked_genes( self ): self.logout() self.login( email='*****@*****.**' ) admin_user = sa_session.query( galaxy.model.User ) \ .filter( galaxy.model.User.table.c.email=='*****@*****.**' ) \ .one() self.new_history( name='DNAseHSS_flanked_genes' ) history1 = sa_session.query( galaxy.model.History ) \ .filter( and_( galaxy.model.History.table.c.deleted==False, galaxy.model.History.table.c.user_id==admin_user.id ) ) \ .order_by( desc( galaxy.model.History.table.c.create_time ) ) \ .first() track_params = dict( db="hg17", hgta_group="regulation", hgta_table="dukeDnaseCd4Sites", hgta_track="dukeDnaseCd4Sites", hgta_regionType="range", position="chr22", hgta_outputType="bed", sendToGalaxy="1" ) output_params = dict( fbQual="whole", ) # Test 1 self.run_ucsc_main( track_params, output_params ) self.wait() self.verify_dataset_correctness('DNAseHSS.dat') latest_hda = sa_session.query( galaxy.model.HistoryDatasetAssociation ) \ .order_by( desc( galaxy.model.HistoryDatasetAssociation.table.c.create_time ) ) \ .first() # Due to twill not being able to handle the permissions forms, we'll eliminate # DefaultHistoryPermissions prior to uploading a dataset so that the permission # form will not be displayed on ted edit attributes page. for dp in latest_hda.dataset.actions: sa_session.delete( dp ) sa_session.flush() sa_session.refresh( latest_hda.dataset ) self.edit_hda_attribute_info( str( latest_hda.id ), new_name="DNAse HS" ) self.check_metadata_for_string( "DNAse HS" ) track_params = dict( db="hg17", hgta_group="genes", hgta_table="knownGene", hgta_track="knownGene", hgta_regionType="range", position="chr22", hgta_outputType="bed", sendToGalaxy="1" ) output_params = dict( fbQual="whole", ) # Test 2 self.run_ucsc_main( track_params, output_params ) self.wait() self.verify_dataset_correctness('hg17chr22KnownGenes.dat') latest_hda = sa_session.query( galaxy.model.HistoryDatasetAssociation ) \ .order_by( desc( galaxy.model.HistoryDatasetAssociation.table.c.create_time ) ) \ .first() for dp in latest_hda.dataset.actions: sa_session.delete( dp ) sa_session.flush() sa_session.refresh( latest_hda.dataset ) self.edit_hda_attribute_info( str( latest_hda.id ), new_name="Genes" ) self.check_metadata_for_string( "Genes" ) # Test 3 self.run_tool( 'get_flanks1', input="2", region="whole", direction="Upstream", offset="0", size="500" ) self.wait() self.verify_dataset_correctness( 'knownGeneUpstream500Flanks.dat' ) latest_hda = sa_session.query( galaxy.model.HistoryDatasetAssociation ) \ .order_by( desc( galaxy.model.HistoryDatasetAssociation.table.c.create_time ) ) \ .first() for dp in latest_hda.dataset.actions: sa_session.delete( dp ) sa_session.flush() sa_session.refresh( latest_hda.dataset ) self.edit_hda_attribute_info( str( latest_hda.id ), new_name="Flanks" ) self.check_metadata_for_string( "Flanks" ) # Test 4 self.run_tool( 'gops_join_1', input1="3", input2="1", min="1", fill="none" ) self.wait() # We cannot verify this dataset, because this tool spits out data in a non-deterministic order #self.verify_dataset_correctness( 'joinFlanksDNAse.dat' ) # Test 5 self.run_tool( 'Filter1', input="4", cond="c17==1000" ) self.wait() self.verify_dataset_correctness( 'filteredJoinedFlanksDNAse.dat' ) self.delete_history( self.security.encode_id( history1.id ) ) self.logout()