Skip to content

Commit

Permalink
checking processed data status
Browse files Browse the repository at this point in the history
  • Loading branch information
antgonza committed Apr 3, 2015
1 parent 2fa574e commit d63fb3e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
12 changes: 6 additions & 6 deletions qiita_db/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,14 +1270,14 @@ def delete(cls, processed_data_id):
------
QiitaDBUnknownIDError
If the processed data id doesn't exist
QiitaDBError
If the processed data has been used in an analysis
QiitaDBStatusError
If the processed data status is not sandbox
"""
conn_handler = SQLConnectionHandler()
if cls(processed_data_id).status != 'sandbox':
raise QiitaDBStatusError(
"Illegal operation on public processed data")

# check if the raw data exist
if not cls.exists(processed_data_id):
raise QiitaDBUnknownIDError(processed_data_id, "processed data")
conn_handler = SQLConnectionHandler()

analysis_ids = [str(_id[0]) for _id in conn_handler.execute_fetchall(
"SELECT DISTINCT analysis_id FROM qiita.analysis_sample WHERE "
Expand Down
7 changes: 4 additions & 3 deletions qiita_db/test/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,17 +786,18 @@ def test_create(self):
self.assertEqual(obs, [[1, 2]])

def test_delete(self):
"""Correctly deletes a processed data and raises an error if id doesn't
exists or if it has been used in a (meta)analysis"""
"""Correctly deletes a processed data and raises an error if it has
been used in a (meta)analysis or if it's public"""
pd = ProcessedData.create(self.params_table, self.params_id,
self.filepaths,
preprocessed_data=self.preprocessed_data,
processed_date=self.date)
ProcessedData.delete(pd.id)

with self.assertRaises(QiitaDBUnknownIDError):
ProcessedData.delete(pd.id)

with self.assertRaises(QiitaDBError):
with self.assertRaises(QiitaDBStatusError):
ProcessedData.delete(1)

def test_create_no_date(self):
Expand Down

0 comments on commit d63fb3e

Please sign in to comment.