|
16 | 16 |
|
17 | 17 | from tornado.web import HTTPError |
18 | 18 | import pandas as pd |
| 19 | +from biom import example_table as et |
| 20 | +from biom.util import biom_open |
19 | 21 |
|
20 | 22 | from qiita_db.handlers.tests.oauthbase import OauthTestingBase |
21 | 23 | import qiita_db as qdb |
@@ -206,6 +208,27 @@ def test_post(self): |
206 | 208 | self._clean_up_files.extend([fp for _, fp, _ in a.filepaths]) |
207 | 209 | self.assertEqual(a.name, "New test artifact") |
208 | 210 |
|
| 211 | + def test_post_analysis(self): |
| 212 | + fd, fp = mkstemp(suffix='_table.biom') |
| 213 | + close(fd) |
| 214 | + with biom_open(fp, 'w') as f: |
| 215 | + et.to_hdf5(f, "test") |
| 216 | + self._clean_up_files.append(fp) |
| 217 | + |
| 218 | + data = {'filepaths': dumps([(fp, 'biom')]), |
| 219 | + 'type': "BIOM", |
| 220 | + 'name': "New biom artifact", |
| 221 | + 'analysis': 1, |
| 222 | + 'data_type': '16S'} |
| 223 | + obs = self.post('/apitest/artifact/', headers=self.header, data=data) |
| 224 | + self.assertEqual(obs.code, 200) |
| 225 | + obs = loads(obs.body) |
| 226 | + self.assertEqual(obs.keys(), ['artifact']) |
| 227 | + |
| 228 | + a = qdb.artifact.Artifact(obs['artifact']) |
| 229 | + self._clean_up_files.extend([afp for _, afp, _ in a.filepaths]) |
| 230 | + self.assertEqual(a.name, "New biom artifact") |
| 231 | + |
209 | 232 | def test_post_error(self): |
210 | 233 | data = {'filepaths': dumps([('Do not exist', 'raw_forward_seqs')]), |
211 | 234 | 'type': "FASTQ", |
|
0 commit comments