Skip to content

Commit a095c60

Browse files
committed
Adding a test for the error
1 parent 2c83241 commit a095c60

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

qiita_ware/test/test_ebi.py

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
from qiita_ware.ebi import (SampleAlreadyExistsError, NoXMLError,
2323
EBISubmission)
24+
from qiita_ware.exceptions import EBISumbissionError
2425
from qiita_core.qiita_settings import qiita_config
2526

2627

@@ -385,6 +386,16 @@ def test_add_samples_from_templates(self):
385386
with self.assertRaises(KeyError):
386387
submission.samples['nothere']
387388

389+
def test_add_samples_from_templates_error(self):
390+
sample_template = StringIO(SAMPLE_TEMPLATE_ERROR)
391+
prep_template = StringIO(EXP_PREP_TEMPLATE)
392+
submission = EBISubmission('001', 'teststudy', 'test asbstract',
393+
investigation_type='Other',
394+
new_investigation_type='metagenome')
395+
self.assertRaises(
396+
EBISumbissionError, submission.add_samples_from_templates,
397+
sample_template, prep_template, self.path)
398+
388399
def test_add_samples_from_templates_bad_directory(self):
389400
sample_template = StringIO(EXP_SAMPLE_TEMPLATE)
390401
prep_template = StringIO(EXP_PREP_TEMPLATE)
@@ -648,11 +659,30 @@ def test_generate_curl_command(self):
648659
</design>
649660
"""
650661

662+
SAMPLE_TEMPLATE_ERROR = (
663+
"sample_name\tcollection_timestamp\tdescription\thas_extracted_data\t"
664+
"has_physical_specimen\thost_subject_id\tlatitude\tlongitude\t"
665+
"physical_location\trequired_sample_info_status_id\tsample_type\t"
666+
"str_column\n"
667+
"sample1\t2014-05-29 12:24:51\tTest Sample 1\tTrue\tTrue\tNotIdentified\t"
668+
"42.42\t41.41\tlocation1\t1\ttype1\tValue for sample 1\n"
669+
"sample2\t2014-05-29 12:24:51\tTest Sample 2\tTrue\tTrue\tNotIdentified\t"
670+
"4.2\t1.1\tlocation1\t1\ttype1\tValue for sample 2\n"
671+
"sample3\t2014-05-29 12:24:51\tTest Sample 3\tTrue\tTrue\tNotIdentified\t"
672+
"4.8\t4.41\tlocation1\t1\ttype1\tValue for sample 3\n")
673+
651674
EXP_SAMPLE_TEMPLATE = (
652-
"sample_name\tcollection_timestamp\tdescription\thas_extracted_data\thas_physical_specimen\thost_subject_id\tlatitude\tlongitude\tphysical_location\trequired_sample_info_status_id\tsample_type\tstr_column\ttaxon_id\tscientific_name\n"
653-
"sample1\t2014-05-29 12:24:51\tTest Sample 1\tTrue\tTrue\tNotIdentified\t42.42\t41.41\tlocation1\t1\ttype1\tValue for sample 1\t9606\thomo sapiens\n"
654-
"sample2\t2014-05-29 12:24:51\tTest Sample 2\tTrue\tTrue\tNotIdentified\t4.2\t1.1\tlocation1\t1\ttype1\tValue for sample 2\t9606\thomo sapiens\n"
655-
"sample3\t2014-05-29 12:24:51\tTest Sample 3\tTrue\tTrue\tNotIdentified\t4.8\t4.41\tlocation1\t1\ttype1\tValue for sample 3\t9606\thomo sapiens\n")
675+
"sample_name\tcollection_timestamp\tdescription\thas_extracted_data\t"
676+
"has_physical_specimen\thost_subject_id\tlatitude\tlongitude\t"
677+
"physical_location\trequired_sample_info_status_id\tsample_type\t"
678+
"str_column\ttaxon_id\tscientific_name\n"
679+
"sample1\t2014-05-29 12:24:51\tTest Sample 1\tTrue\tTrue\tNotIdentified\t"
680+
"42.42\t41.41\tlocation1\t1\ttype1\tValue for sample 1\t9606\t"
681+
"homo sapiens\n"
682+
"sample2\t2014-05-29 12:24:51\tTest Sample 2\tTrue\tTrue\tNotIdentified\t"
683+
"4.2\t1.1\tlocation1\t1\ttype1\tValue for sample 2\t9606\thomo sapiens\n"
684+
"sample3\t2014-05-29 12:24:51\tTest Sample 3\tTrue\tTrue\tNotIdentified\t"
685+
"4.8\t4.41\tlocation1\t1\ttype1\tValue for sample 3\t9606\thomo sapiens\n")
656686

657687
EXP_PREP_TEMPLATE = (
658688
"sample_name\tcenter_name\tcenter_project_name\tdata_type_id\t"

0 commit comments

Comments
 (0)