Skip to content

Commit 3974fb7

Browse files
committed
addressing @ElDeveloper and @squirrelo comments
1 parent 1bb2c91 commit 3974fb7

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

qiita_db/data.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -830,13 +830,14 @@ def delete(cls, ppd_id):
830830
if ppd.status != 'sandbox':
831831
raise QiitaDBStatusError(
832832
"Illegal operation on non sandbox preprocessed data")
833-
elif (ppd.submitted_to_vamps_status() not in valid_submission_states or
834-
ppd.submitted_to_insdc_status() not in valid_submission_states):
833+
elif ppd.submitted_to_vamps_status() not in valid_submission_states:
835834
raise QiitaDBStatusError(
836-
"Illegal operation due to EBI submission status ('%s') or "
837-
"VAMPS submission status ('%s')" % (
838-
ppd.submitted_to_insdc_status(),
839-
ppd.submitted_to_vamps_status()))
835+
"Illegal operation. This preprocessed data has or is being "
836+
"added to VAMPS.")
837+
elif ppd.submitted_to_insdc_status() not in valid_submission_states:
838+
raise QiitaDBStatusError(
839+
"Illegal operation. This preprocessed data has or is being "
840+
"added to EBI.")
840841

841842
conn_handler = SQLConnectionHandler()
842843

qiita_db/test/test_data.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ def test_create_data_type_only(self):
478478
# preprocessed_data_id, filepath_id
479479
self.assertEqual(obs, [[3, obs_id - 1], [3, obs_id]])
480480

481-
def test_delete(self):
481+
def test_delete_basic(self):
482482
"""Correctly deletes a preprocessed data"""
483483
# testing regular delete
484484
ppd = PreprocessedData.create(
@@ -496,18 +496,24 @@ def test_delete(self):
496496
with self.assertRaises(QiitaDBStatusError):
497497
PreprocessedData.delete(1)
498498

499+
def test_delete_advance(self):
499500
# testing that we can not remove cause preprocessed data has been
500501
# submitted to EBI or VAMPS
501-
pd = ProcessedData(1)
502-
pd.status = 'sandbox'
503-
with self.assertRaises(QiitaDBError):
504-
PreprocessedData.delete(pd.preprocessed_data)
502+
ppd = PreprocessedData.create(
503+
self.study, self.params_table,
504+
self.params_id, self.filepaths, prep_template=self.prep_template,
505+
ebi_submission_accession=self.ebi_submission_accession,
506+
ebi_study_accession=self.ebi_study_accession)
505507

506-
# testing that we can not remove cause preprocessed data has processed
507-
# data
508-
ppd = PreprocessedData(pd.preprocessed_data)
509-
ppd.update_insdc_status('not submitted')
510-
with self.assertRaises(QiitaDBError):
508+
# fails due to VAMPS submission
509+
ppd.update_vamps_status('success')
510+
with self.assertRaises(QiitaDBStatusError):
511+
PreprocessedData.delete(ppd.id)
512+
ppd.update_vamps_status('failed')
513+
514+
# fails due to EBI submission
515+
ppd.update_insdc_status('success', 'AAAA', 'AAAA')
516+
with self.assertRaises(QiitaDBStatusError):
511517
PreprocessedData.delete(ppd.id)
512518

513519
def test_create_error_dynamic_table(self):

0 commit comments

Comments
 (0)