Ejemplo n.º 1
0
    def delete_processed_data(self, study, user, callback):
        """Delete the selected processed 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
        """
        pd_id = int(self.get_argument('processed_data_id'))

        try:
            ProcessedData.delete(pd_id)
            msg = ("Processed data %d has been deleted" % pd_id)
            msg_level = "success"
            pd_id = None
        except Exception as e:
            msg = ("Couldn't remove processed data %d: %s" %
                   (pd_id, str(e)))
            msg_level = "danger"

        callback((msg, msg_level, 'processed_data_tab', pd_id, None))
Ejemplo n.º 2
0
    def test_delete(self):
        """Correctly deletes a processed data"""
        # testing regular delete
        pd = ProcessedData.create(self.params_table, self.params_id,
                                  self.filepaths,
                                  preprocessed_data=self.preprocessed_data,
                                  processed_date=self.date)
        ProcessedData.delete(pd.id)

        # testing that it raises an error if ID doesn't exist
        with self.assertRaises(QiitaDBUnknownIDError):
            ProcessedData.delete(pd.id)

        # testing that we can not remove cause the processed data != sandbox
        with self.assertRaises(QiitaDBStatusError):
            ProcessedData.delete(1)

        # testing that we can not remove cause processed data has analyses
        pd = ProcessedData(1)
        pd.status = 'sandbox'
        with self.assertRaises(QiitaDBError):
            ProcessedData.delete(1)