Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions qiita_client/qiita_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,28 @@ def artifact_and_preparation_files(self, artifact_id,

return files, prep_info

def get_artifact_html_summary(self, artifact_id):
"""Gets the artifact html_summary

Parameters
----------
artifact_id : int
The artifact id

Returns
-------
None or str
filepath of the artifact html_summary
"""
html_summary_fp = None
artifact_info = self.get("/qiita_db/artifacts/%s/" % artifact_id)

if 'html_summary' in artifact_info['files']:
html_summary_fp = artifact_info[
'files']['html_summary'][0]['filepath']

return html_summary_fp

def _process_files_per_sample_fastq(self, files, prep_info,
ignore_small_files):
"helper function to process per_sample_FASTQ artifacts and their preps"
Expand Down
14 changes: 12 additions & 2 deletions qiita_client/tests/test_qiita_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,26 @@ def test_post_error(self):
self.tester.post("/qiita_db/artifacts/1/type/")

def test_patch(self):
artifact_id = '2'

# before we patch the artifact by adding the html_summary, the
# html_summary should be None
self.assertIsNone(self.tester.get_artifact_html_summary(artifact_id))

# now, let's patch
fd, fp = mkstemp()
close(fd)
with open(fp, 'w') as f:
f.write('\n')
self.clean_up_files.append(fp)

obs = self.tester.patch('/qiita_db/artifacts/2/', 'add',
obs = self.tester.patch(f'/qiita_db/artifacts/{artifact_id}/', 'add',
'/html_summary/', value=fp)
self.assertIsNone(obs)

# now, the html_summary should contain the filename fp
self.assertTrue(
basename(fp) in self.tester.get_artifact_html_summary(artifact_id))

def test_patch_error(self):
with self.assertRaises(BadRequestError):
self.tester.patch(
Expand Down
Loading