def test_plugin_validate(self): fp = join(self.out_dir, 'prefix1.fastq') with open(fp, 'w') as f: f.write(READS) fp2 = join(self.out_dir, 'prefix1_b.fastq') with open(fp2, 'w') as f: f.write(BARCODES) prep_info = {"1.SKB2.640194": {"not_a_run_prefix": "prefix1"}} files = {'raw_forward_seqs': [fp], 'raw_barcodes': [fp2]} atype = "FASTQ" data = {'prep_info': dumps(prep_info), 'study': 1, 'data_type': '16S'} template = self.qclient.post('/apitest/prep_template/', data=data)['prep'] parameters = { 'template': template, 'files': dumps(files), 'artifact_type': atype } data = { 'command': dumps(['Target Gene type', '0.1.0', 'Validate']), 'parameters': dumps(parameters), 'status': 'running' } job_id = self.qclient.post('/apitest/processing_job/', data=data)['job'] plugin("https://localhost:21174", job_id, self.out_dir) self._wait_job(job_id) obs = self.qclient.get_job_info(job_id) self.assertEqual(obs['status'], 'success')
def test_plugin_summary(self): artifact_id = 1 data = { 'command': dumps(['Target Gene type', '0.1.0', 'Generate HTML summary']), 'parameters': dumps({'input_data': artifact_id}), 'status': 'running' } job_id = self.qclient.post('/apitest/processing_job/', data=data)['job'] # Qiita will return a filepath, but in the test environment, these # files do not exist - create them files = self.qclient.get('/qiita_db/artifacts/%s/' % artifact_id)['files'] bcds_fp = files['raw_barcodes'][0] self._clean_up_files.append(bcds_fp) with GzipFile(bcds_fp, mode='w', mtime=1) as fh: fh.write(BARCODES) fwd_fp = files['raw_forward_seqs'][0] self._clean_up_files.append(fwd_fp) with GzipFile(fwd_fp, mode='w', mtime=1) as fh: fh.write(READS) plugin("https://localhost:21174", job_id, self.out_dir) self._wait_job(job_id) obs = self.qclient.get_job_info(job_id) self.assertEqual(obs['status'], 'success')
def test_plugin_validate(self): fp = join(self.out_dir, 'prefix1.fastq') with open(fp, 'w') as f: f.write(READS) fp2 = join(self.out_dir, 'prefix1_b.fastq') with open(fp2, 'w') as f: f.write(BARCODES) prep_info = {"1.SKB2.640194": {"not_a_run_prefix": "prefix1"}} files = {'raw_forward_seqs': [fp], 'raw_barcodes': [fp2]} atype = "FASTQ" data = {'prep_info': dumps(prep_info), 'study': 1, 'data_type': '16S'} template = self.qclient.post( '/apitest/prep_template/', data=data)['prep'] parameters = {'template': template, 'files': dumps(files), 'artifact_type': atype} data = {'command': dumps(['Target Gene type', '0.1.0', 'Validate']), 'parameters': dumps(parameters), 'status': 'running'} job_id = self.qclient.post( '/apitest/processing_job/', data=data)['job'] plugin("https://localhost:21174", job_id, self.out_dir) self._wait_job(job_id) obs = self.qclient.get_job_info(job_id) self.assertEqual(obs['status'], 'success')
def test_plugin_summary(self): artifact_id = 1 data = {'command': dumps(['Target Gene type', '0.1.0', 'Generate HTML summary']), 'parameters': dumps({'input_data': artifact_id}), 'status': 'running'} job_id = self.qclient.post( '/apitest/processing_job/', data=data)['job'] # Qiita will return a filepath, but in the test environment, these # files do not exist - create them files = self.qclient.get( '/qiita_db/artifacts/%s/' % artifact_id)['files'] bcds_fp = files['raw_barcodes'][0] self._clean_up_files.append(bcds_fp) with GzipFile(bcds_fp, mode='w', mtime=1) as fh: fh.write(BARCODES) fwd_fp = files['raw_forward_seqs'][0] self._clean_up_files.append(fwd_fp) with GzipFile(fwd_fp, mode='w', mtime=1) as fh: fh.write(READS) plugin("https://localhost:21174", job_id, self.out_dir) self._wait_job(job_id) obs = self.qclient.get_job_info(job_id) self.assertEqual(obs['status'], 'success')
def test_plugin_error(self): parameters = {'template': 1, 'files': dumps({'log': ['/path/to/file1.log']}), 'artifact_type': "Demultiplexed"} data = {'command': dumps(['Target Gene type', '0.1.0', 'Validate']), 'parameters': dumps(parameters), 'status': 'running'} job_id = self.qclient.post( '/apitest/processing_job/', data=data)['job'] plugin("https://localhost:21174", job_id, self.out_dir) self._wait_job(job_id) obs = self.qclient.get_job_info(job_id) self.assertEqual(obs['status'], 'error')
def test_plugin_error(self): parameters = { 'template': 1, 'files': dumps({'log': ['/path/to/file1.log']}), 'artifact_type': "Demultiplexed" } data = { 'command': dumps(['Target Gene type', '0.1.0', 'Validate']), 'parameters': dumps(parameters), 'status': 'running' } job_id = self.qclient.post('/apitest/processing_job/', data=data)['job'] plugin("https://localhost:21174", job_id, self.out_dir) self._wait_job(job_id) obs = self.qclient.get_job_info(job_id) self.assertEqual(obs['status'], 'error')