9
9
from json import dumps
10
10
11
11
from qiita_core .util import qiita_test_checker
12
- from qiita_db .util import get_count
13
12
from qiita_db .processing_job import ProcessingWorkflow
14
13
from qiita_db .software import Command , Parameters
15
14
from qiita_db .user import User
@@ -38,20 +37,36 @@ def test_process_artifact_handler_get_req(self):
38
37
self .assertEqual (obs , exp )
39
38
40
39
def test_list_commands_handler_get_req (self ):
41
- obs = list_commands_handler_get_req ('FASTQ' )
40
+ obs = list_commands_handler_get_req ('FASTQ' , True )
42
41
exp = {'status' : 'success' ,
43
42
'message' : '' ,
44
43
'commands' : [{'id' : 1 , 'command' : 'Split libraries FASTQ' ,
45
44
'output' : [['demultiplexed' , 'Demultiplexed' ]]}]}
46
45
self .assertEqual (obs , exp )
47
46
48
- obs = list_commands_handler_get_req ('Demultiplexed' )
47
+ obs = list_commands_handler_get_req ('Demultiplexed' , True )
49
48
exp = {'status' : 'success' ,
50
49
'message' : '' ,
51
50
'commands' : [{'id' : 3 , 'command' : 'Pick closed-reference OTUs' ,
52
51
'output' : [['OTU table' , 'BIOM' ]]}]}
53
52
self .assertEqual (obs , exp )
54
53
54
+ obs = list_commands_handler_get_req ('BIOM' , False )
55
+ exp = {'status' : 'success' ,
56
+ 'message' : '' ,
57
+ 'commands' : [
58
+ {'command' : 'Summarize Taxa' , 'id' : 11 ,
59
+ 'output' : [['taxa_summary' , 'taxa_summary' ]]},
60
+ {'command' : 'Beta Diversity' , 'id' : 12 ,
61
+ 'output' : [['distance_matrix' , 'distance_matrix' ]]},
62
+ {'command' : 'Alpha Rarefaction' , 'id' : 13 ,
63
+ 'output' : [['rarefaction_curves' , 'rarefaction_curves' ]]},
64
+ {'command' : 'Single Rarefaction' , 'id' : 14 ,
65
+ 'output' : [['rarefied_table' , 'BIOM' ]]}]}
66
+ # since the order of the commands can change, test them separately
67
+ self .assertItemsEqual (obs .pop ('commands' ), exp .pop ('commands' ))
68
+ self .assertEqual (obs , exp )
69
+
55
70
def test_list_options_handler_get_req (self ):
56
71
obs = list_options_handler_get_req (3 )
57
72
exp = {'status' : 'success' ,
@@ -64,11 +79,20 @@ def test_list_options_handler_get_req(self):
64
79
'sortmerna_e_value' : 1 ,
65
80
'sortmerna_max_pos' : 10000 ,
66
81
'threads' : 1 }}],
67
- 'req_options' : {'input_data' : ('artifact' , ['Demultiplexed' ])}}
82
+ 'req_options' : {'input_data' : ('artifact' , ['Demultiplexed' ])},
83
+ 'opt_options' : {'reference' : ['reference' , '1' ],
84
+ 'similarity' : ['float' , '0.97' ],
85
+ 'sortmerna_coverage' : ['float' , '0.97' ],
86
+ 'sortmerna_e_value' : ['float' , '1' ],
87
+ 'sortmerna_max_pos' : ['integer' , '10000' ],
88
+ 'threads' : ['integer' , '1' ]}}
89
+ # First check that the keys are the same
90
+ self .assertItemsEqual (obs , exp )
68
91
self .assertEqual (obs ['status' ], exp ['status' ])
69
92
self .assertEqual (obs ['message' ], exp ['message' ])
70
93
self .assertEqual (obs ['options' ], exp ['options' ])
71
94
self .assertEqual (obs ['req_options' ], exp ['req_options' ])
95
+ self .assertEqual (obs ['opt_options' ], exp ['opt_options' ])
72
96
73
97
def test_job_ajax_get_req (self ):
74
98
obs = job_ajax_get_req ("063e553b-327c-4818-ab4a-adfe58e49860" )
@@ -94,15 +118,21 @@ def test_job_ajax_get_req(self):
94
118
@qiita_test_checker ()
95
119
class TestProcessingAPI (TestCase ):
96
120
def test_workflow_handler_post_req (self ):
97
- next_id = get_count ('qiita.processing_job_workflow_root' ) + 1
98
- obs = workflow_handler_post_req ("test@foo.bar" , 1 , '{"input_data": 1}' )
99
- wf = ProcessingWorkflow (next_id )
121
+ params = ('{"max_barcode_errors": 1.5, "barcode_type": "golay_12", '
122
+ '"max_bad_run_length": 3, "phred_offset": "auto", '
123
+ '"rev_comp": false, "phred_quality_threshold": 3, '
124
+ '"input_data": 1, "rev_comp_barcode": false, '
125
+ '"rev_comp_mapping_barcodes": false, '
126
+ '"min_per_read_length_fraction": 0.75, "sequence_max_n": 0}' )
127
+ obs = workflow_handler_post_req ("test@foo.bar" , 1 , params )
128
+ wf_id = obs ['workflow_id' ]
129
+ wf = ProcessingWorkflow (wf_id )
100
130
nodes = wf .graph .nodes ()
101
131
self .assertEqual (len (nodes ), 1 )
102
132
job = nodes [0 ]
103
133
exp = {'status' : 'success' ,
104
134
'message' : '' ,
105
- 'workflow_id' : next_id ,
135
+ 'workflow_id' : wf_id ,
106
136
'job' : {'id' : job .id ,
107
137
'inputs' : [1 ],
108
138
'label' : "Split libraries FASTQ" ,
0 commit comments