Skip to content

Commit 2c83241

Browse files
committed
Fixing tests
1 parent 407f48e commit 2c83241

File tree

1 file changed

+27
-33
lines changed

1 file changed

+27
-33
lines changed

qiita_ware/test/test_ebi.py

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ def test_get_sample_alias(self):
108108
e = EBISubmission('2', 'Study Title', 'Study Abstract',
109109
investigation_type='Other',
110110
new_investigation_type='metagenome')
111-
e.add_sample('foo')
111+
e.add_sample('foo', '9606', 'homo sapiens', 'desc1')
112112
exp = '%s_ppdid_2:foo' % qiita_config.ebi_organization_prefix
113113
self.assertEqual(e._get_sample_alias('foo'), exp)
114114

115115
def test_get_experiment_alias(self):
116116
e = EBISubmission('2', 'Study Title', 'Study Abstract',
117117
investigation_type='Other',
118118
new_investigation_type='metagenome')
119-
e.add_sample('foo')
119+
e.add_sample('foo', '9606', 'homo sapiens', 'desc1')
120120
exp = '%s_ppdid_2:foo' % qiita_config.ebi_organization_prefix
121121
self.assertEqual(e._get_experiment_alias('foo'), exp)
122122

@@ -174,19 +174,19 @@ def test_add_sample(self):
174174
submission = EBISubmission('001', 'teststudy', 'test asbstract',
175175
investigation_type='Other',
176176
new_investigation_type='metagenome')
177-
submission.add_sample('test1')
178-
submission.add_sample('test2')
177+
submission.add_sample('test1', '9606', 'homo sapiens', 'desc1')
178+
submission.add_sample('test2', '9606', 'homo sapiens', 'desc2')
179179
samples = submission.samples
180180
self.assertTrue('test1' in samples and 'test2' in samples)
181181
with self.assertRaises(SampleAlreadyExistsError):
182-
submission.add_sample('test1')
182+
submission.add_sample('test1', '9606', 'homo sapiens', 'desc1')
183183

184184
def test_generate_sample_xml(self):
185185
submission = EBISubmission('001', 'teststudy', 'test asbstract',
186186
investigation_type='Other',
187187
new_investigation_type='metagenome')
188-
submission.add_sample('test1')
189-
submission.add_sample('test2')
188+
submission.add_sample('test1', '9606', 'homo sapiens', 'desc1')
189+
submission.add_sample('test2', '9606', 'homo sapiens', 'desc2')
190190
xmlelement = submission.generate_sample_xml()
191191
xml = minidom.parseString(ET.tostring(xmlelement))
192192
xmlstring = xml.toprettyxml(indent=' ', encoding='UTF-8')
@@ -198,8 +198,8 @@ def test_add_sample_prep(self):
198198
submission = EBISubmission('001', 'teststudy', 'test asbstract',
199199
investigation_type='Other',
200200
new_investigation_type='metagenome')
201-
submission.add_sample('test1')
202-
submission.add_sample('test2')
201+
submission.add_sample('test1', '9606', 'homo sapiens', 'desc1')
202+
submission.add_sample('test2', '9606', 'homo sapiens', 'desc1')
203203

204204
submission.add_sample_prep('test1', 'ILLUMINA', 'fastq',
205205
self.sample1_fp, 'experiment description',
@@ -218,8 +218,8 @@ def test_add_sample_prep_exception(self):
218218
submission = EBISubmission('001', 'teststudy', 'test asbstract',
219219
investigation_type='Other',
220220
new_investigation_type='metagenome')
221-
submission.add_sample('test1')
222-
submission.add_sample('test2')
221+
submission.add_sample('test1', '9606', 'homo sapiens', 'desc1')
222+
submission.add_sample('test2', '9606', 'homo sapiens', 'desc1')
223223
with self.assertRaises(ValueError):
224224
submission.add_sample_prep('test2', 'DOES-NOT-EXIST', 'fastq',
225225
self.sample1_fp,
@@ -257,7 +257,7 @@ def test_generate_experiment_xml(self):
257257
submission = EBISubmission('001', 'teststudy', 'test asbstract',
258258
investigation_type='Other',
259259
new_investigation_type='metagenome')
260-
submission.add_sample('test1')
260+
submission.add_sample('test1', '9606', 'homo sapiens', 'desc1')
261261
submission.add_sample_prep('test1', 'ILLUMINA', 'fastq',
262262
self.sample1_fp,
263263
'experiment description',
@@ -276,7 +276,7 @@ def test_generate_run_xml(self):
276276
submission = EBISubmission('001', 'teststudy', 'test asbstract',
277277
investigation_type='Other',
278278
new_investigation_type='metagenome')
279-
submission.add_sample('test1')
279+
submission.add_sample('test1', '9606', 'homo sapiens', 'desc1')
280280
submission.add_sample_prep('test1', 'ILLUMINA', 'fastq',
281281
self.sample1_fp,
282282
'experiment description',
@@ -299,7 +299,7 @@ def test_generate_submission_xml(self):
299299
submission = EBISubmission('001', 'teststudy', 'test asbstract',
300300
investigation_type='Other',
301301
new_investigation_type='metagenome')
302-
submission.add_sample('test1')
302+
submission.add_sample('test1', '9606', 'homo sapiens', 'desc1')
303303
submission.add_sample_prep('test1', 'ILLUMINA', 'fastq',
304304
'__init__.py', 'experiment description',
305305
'library protocol')
@@ -336,8 +336,8 @@ def test_write_sample_xml(self):
336336
submission = EBISubmission('001', 'teststudy', 'test asbstract',
337337
investigation_type='Other',
338338
new_investigation_type='metagenome')
339-
submission.add_sample('test1')
340-
submission.add_sample('test2')
339+
submission.add_sample('test1', '9606', 'homo sapiens', 'desc1')
340+
submission.add_sample('test2', '9606', 'homo sapiens', 'desc2')
341341
fh, output = mkstemp()
342342
close(fh)
343343
submission.write_sample_xml(output)
@@ -351,7 +351,7 @@ def test_write_experiment_xml(self):
351351
submission = EBISubmission('001', 'teststudy', 'test asbstract',
352352
investigation_type='Other',
353353
new_investigation_type='metagenome')
354-
submission.add_sample('test1')
354+
submission.add_sample('test1', '9606', 'homo sapiens', 'desc1')
355355
submission.add_sample_prep('test1', 'ILLUMINA', 'fastq',
356356
self.sample1_fp, 'experiment description',
357357
'library protocol')
@@ -471,17 +471,19 @@ def test_generate_curl_command(self):
471471
COLORADO">
472472
<TITLE>test1</TITLE>
473473
<SAMPLE_NAME>
474-
<TAXON_ID>no_data</TAXON_ID>
474+
<TAXON_ID>9606</TAXON_ID>
475+
<SCIENTIFIC_NAME>homo sapiens</SCIENTIFIC_NAME>
475476
</SAMPLE_NAME>
476-
<DESCRIPTION>no_data</DESCRIPTION>
477+
<DESCRIPTION>desc1</DESCRIPTION>
477478
</SAMPLE>
478479
<SAMPLE alias="%(organization_prefix)s_ppdid_001:test2" center_name="CCME-\
479480
COLORADO">
480481
<TITLE>test2</TITLE>
481482
<SAMPLE_NAME>
482-
<TAXON_ID>no_data</TAXON_ID>
483+
<TAXON_ID>9606</TAXON_ID>
484+
<SCIENTIFIC_NAME>homo sapiens</SCIENTIFIC_NAME>
483485
</SAMPLE_NAME>
484-
<DESCRIPTION>no_data</DESCRIPTION>
486+
<DESCRIPTION>desc2</DESCRIPTION>
485487
</SAMPLE>
486488
</SAMPLE_SET>
487489
""" % {'organization_prefix': qiita_config.ebi_organization_prefix}
@@ -647,18 +649,10 @@ def test_generate_curl_command(self):
647649
"""
648650

649651
EXP_SAMPLE_TEMPLATE = (
650-
"sample_name\tcollection_timestamp\tdescription\thas_extracted_data\t"
651-
"has_physical_specimen\thost_subject_id\tlatitude\tlongitude\t"
652-
"physical_location\trequired_sample_info_status_id\tsample_type\t"
653-
"str_column\n"
654-
"sample1\t2014-05-29 12:24:51\tTest Sample 1\tTrue\tTrue\tNotIdentified\t"
655-
"42.42\t41.41\tlocation1\t1\ttype1\tValue for sample 1\n"
656-
"sample2\t2014-05-29 12:24:51\t"
657-
"Test Sample 2\tTrue\tTrue\tNotIdentified\t4.2\t1.1\tlocation1\t1\t"
658-
"type1\tValue for sample 2\n"
659-
"sample3\t2014-05-29 12:24:51\tTest Sample 3\tTrue\t"
660-
"True\tNotIdentified\t4.8\t4.41\tlocation1\t1\ttype1\t"
661-
"Value for sample 3\n")
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")
662656

663657
EXP_PREP_TEMPLATE = (
664658
"sample_name\tcenter_name\tcenter_project_name\tdata_type_id\t"

0 commit comments

Comments
 (0)