def delete_preprocessed_data(self, study, user, callback): """Delete the selected preprocessed data Parameters ---------- study : Study The current study object user : User The current user object callback : function The callback function to call with the results once the processing is done """ ppd_id = int(self.get_argument('preprocessed_data_id')) try: PreprocessedData.delete(ppd_id) msg = ("Preprocessed data %d has been deleted" % ppd_id) msg_level = "success" ppd_id = None except Exception as e: msg = ("Couldn't remove preprocessed data %d: %s" % (ppd_id, str(e))) msg_level = "danger" callback((msg, msg_level, 'preprocessed_data_tab', ppd_id, None))
def test_delete_advanced(self): # testing that we can not remove cause preprocessed data has been # submitted to EBI or VAMPS ppd = PreprocessedData.create( self.study, self.params_table, self.params_id, self.filepaths, prep_template=self.prep_template) # fails due to VAMPS submission ppd.update_vamps_status('success') with self.assertRaises(QiitaDBStatusError): PreprocessedData.delete(ppd.id) ppd.update_vamps_status('failed') ppd = PreprocessedData(1) with self.assertRaises(QiitaDBStatusError): PreprocessedData.delete(ppd.id)
def test_delete_basic(self): """Correctly deletes a preprocessed data""" # testing regular delete ppd = PreprocessedData.create( self.study, self.params_table, self.params_id, self.filepaths, prep_template=self.prep_template) PreprocessedData.delete(ppd.id) # testing that the deleted preprocessed data can't be instantiated with self.assertRaises(QiitaDBUnknownIDError): PreprocessedData(ppd.id) # and for completeness testing that it raises an error if ID # doesn't exist with self.assertRaises(QiitaDBUnknownIDError): PreprocessedData.delete(ppd.id) # testing that we can not remove cause the preprocessed data != sandbox with self.assertRaises(QiitaDBStatusError): PreprocessedData.delete(1)