Skip to content

Commit 50d2109

Browse files
committed
rewrite scenarios
1 parent 14b5a19 commit 50d2109

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

qiita_db/artifact.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -329,16 +329,6 @@ def create(
329329
qiita_db.artifact.Artifact
330330
A new instance of Artifact
331331
332-
Raises
333-
------
334-
QiitaDBArtifactCreationError
335-
If `filepaths` is not provided
336-
If both `parents` and `prep_template` are provided
337-
If none of `parents` and `prep_template` are provided
338-
If `parents` is provided but `processing_parameters` is not
339-
If both `prep_template` and `processing_parameters` is provided
340-
If not all the artifacts in `parents` belong to the same study
341-
342332
Notes
343333
-----
344334
The visibility of the artifact is set by default to `sandbox` if
@@ -353,18 +343,30 @@ def create(
353343
"at least one filepath is required."
354344
)
355345

356-
if bool(parents) != bool(processing_parameters):
357-
# When provided, parents and processing parameters both should be
358-
# provided (this is effectively doing an XOR)
346+
# Check that the combination of parameters is correct
347+
if bool(parents) and bool(prep_template):
359348
raise qdb.exceptions.QiitaDBArtifactCreationError(
360-
"When provided, both parents and processing parameters should "
361-
"be provided"
349+
"Not valid: parents and prep_template provided"
350+
)
351+
elif bool(parents) and not bool(processing_parameters):
352+
raise qdb.exceptions.QiitaDBArtifactCreationError(
353+
"Not valid: both parents and processing_parameters need to be provided"
354+
)
355+
elif bool(prep_template) and bool(processing_parameters):
356+
raise qdb.exceptions.QiitaDBArtifactCreationError(
357+
"Not valid: both prep_template and processing_parameters provided"
358+
)
359+
elif not bool(parents) and not bool(prep_template):
360+
raise qdb.exceptions.QiitaDBArtifactCreationError(
361+
"Not valid: both parents and prep_template need to be provided"
362362
)
363363
elif bool(analysis) and not bool(data_type):
364-
# When provided, analysis and data_type both should be
365-
# provided (this is effectively doing an XOR)
366364
raise qdb.exceptions.QiitaDBArtifactCreationError(
367-
"When provided, both analysis and data_type should be provided"
365+
"Not valid: both analysis and data_type need to be provided"
366+
)
367+
elif bool(prep_template) and bool(data_type):
368+
raise qdb.exceptions.QiitaDBArtifactCreationError(
369+
"Not valid: both prep_template and data_type need to be provided"
368370
)
369371

370372
# There are three different ways of creating an Artifact, but all of

0 commit comments

Comments
 (0)