def test_prep_template_post_req(self): obs = prep_template_post_req(1, '*****@*****.**', 'update.txt', '16S') exp = {'status': 'warning', 'message': [ 'Sample names were already prefixed with the study id.', ('Some columns required to generate a QIIME-compliant ' 'mapping file are not present in the template. A ' 'placeholder value (XXQIITAXX) has been used to populate ' 'these columns. Missing columns: BarcodeSequence, ' 'LinkerPrimerSequence'), ('Some functionality will be disabled due to missing ' 'columns:'), ('\tDemultiplexing with multiple input files disabled.: ' 'barcode, primer, run_prefix;'), '\tDemultiplexing disabled.: barcode, primer;', ('\tEBI submission disabled: center_name, ' 'experiment_design_description, instrument_model, ' 'library_construction_protocol, platform, primer.'), ('See the Templates tutorial for a description of these ' 'fields.')], 'file': 'update.txt', 'id': 'ignored in test'} self.assertItemsEqual(obs['message'].split('\n'), exp['message']) self.assertEqual(obs['status'], exp['status']) self.assertEqual(obs['file'], exp['file']) self.assertIsInstance(obs['id'], int) # Make sure new prep template added prep = PrepTemplate(obs['id']) self.assertEqual(prep.data_type(), '16S') self.assertEqual([x for x in prep.keys()], ['1.SKD6.640190']) self.assertEqual([x._to_dict() for x in prep.values()], [{'new_col': 'new_value'}])
def test_prep_template_post_req_errors(self): # User doesn't have access obs = prep_template_post_req(1, '*****@*****.**', 'filepath', '16S') exp = {'status': 'error', 'message': 'User does not have access to study'} self.assertEqual(obs, exp) # The file does not exist obs = prep_template_post_req(1, '*****@*****.**', 'badfilepath', '16S') exp = {'status': 'error', 'message': 'file does not exist', 'file': 'badfilepath'} self.assertEqual(obs, exp) # Prep template does not exist obs = prep_template_post_req(3100, '*****@*****.**', 'update.txt', '16S') self.assertEqual(obs, {'status': 'error', 'message': 'Study does not exist'})
def test_prep_template_post_req(self): obs = prep_template_post_req(1, '*****@*****.**', 'update.txt', '16S', name=" ") exp = { 'status': 'warning', 'message': [ 'Both a converter and dtype were specified for column ' 'sample_name - only the converter will be used', 'Some ' 'functionality will be disabled due to missing columns:', '\tEBI submission disabled: center_name, ' 'experiment_design_description, instrument_model, ' 'library_construction_protocol, platform;', '\tDemultiplexing disabled.: barcode;', '\tDemultiplexing ' 'with multiple input files disabled.: barcode, primer, ' 'run_prefix.', 'See the Templates tutorial for a ' 'description of these fields.', 'Some columns required to ' 'generate a QIIME-compliant mapping file are not present ' 'in the template. A placeholder value (XXQIITAXX) ' 'has been used to populate these columns. Missing columns: ' 'BarcodeSequence, LinkerPrimerSequence' ], 'file': 'update.txt', 'id': 'ignored in test' } self.assertCountEqual(obs['message'].split('\n'), exp['message']) self.assertEqual(obs['status'], exp['status']) self.assertEqual(obs['file'], exp['file']) self.assertIsInstance(obs['id'], int) # Make sure new prep template added prep = PrepTemplate(obs['id']) self.assertEqual(prep.data_type(), '16S') self.assertEqual([x for x in prep.keys()], ['1.SKD6.640190']) self.assertEqual([x._to_dict() for x in prep.values()], [{ 'new_col': 'new_value' }]) self.assertEqual(prep.name, "Prep information %s" % prep.id)