Skip to content

Commit e4bdfcf

Browse files
committed
add job_id to ArtifactAPItestHandler
1 parent 978ac4f commit e4bdfcf

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

qiita_db/handlers/artifact.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -----------------------------------------------------------------------------
2+
pp = qdb.software.Parameters(parameters_id)
23
# Copyright (c) 2014--, The Qiita Development Team.
34
#
45
# Distributed under the terms of the BSD 3-clause License.
@@ -186,16 +187,28 @@ def post(self):
186187
analysis = self.get_argument('analysis', None)
187188
name = self.get_argument('name', None)
188189
dtype = self.get_argument('data_type', None)
190+
parents = self.get_argument('parents', None)
191+
job_id = self.get_argument('job_id', None)
189192

190193
if prep_template is not None:
191194
prep_template = qdb.metadata_template.prep_template.PrepTemplate(
192195
prep_template)
193196
dtype = None
194197
if analysis is not None:
195198
analysis = qdb.analysis.Analysis(analysis)
199+
if parents is not None:
200+
# remember that this method is only accessed via the tests so
201+
# to load an artifact with parents, the easiest it to use
202+
# the job_id that is being used for testing and passed as a
203+
# parameter
204+
parents = [qdb.artifact.Artifact(p) for p in loads(parents)]
205+
pp = qdb.processing_job.ProcessingJob(job_id).parameters
206+
else:
207+
pp = None
196208

197209
a = qdb.artifact.Artifact.create(
198210
filepaths, artifact_type, name=name, prep_template=prep_template,
211+
parents=parents, processing_parameters=pp,
199212
analysis=analysis, data_type=dtype)
200213

201214
self.write({'artifact': a.id})

0 commit comments

Comments
 (0)