1
by ramon diaz-uriarte
initialized after cleaning up |
1 |
# -*- coding: iso-8859-15 -*-
|
2 |
"""basic_navigation FunkLoad test
|
|
3 |
||
4 |
$Id: $
|
|
5 |
"""
|
|
6 |
import time |
|
7 |
import unittest |
|
8 |
from funkload.FunkLoadTestCase import FunkLoadTestCase |
|
9 |
from webunit.utility import Upload |
|
10 |
||
11 |
||
12 |
auto_refresh_string = 'This is an autorefreshing page' |
|
13 |
MAX_running_time = 3600 * 1 |
|
14 |
||
15 |
||
16 |
||
17 |
def common_part(self, final_output, |
|
18 |
MAX_running_time = 3600, |
|
19 |
auto_refresh_string = auto_refresh_string): |
|
78
by ramon diaz-uriarte
(trying to) prevent false error reports |
20 |
print '\n Start common_part \n' |
1
by ramon diaz-uriarte
initialized after cleaning up |
21 |
server_url = self.server_url |
22 |
start_run = time.time() |
|
23 |
refresh_num = 0 |
|
78
by ramon diaz-uriarte
(trying to) prevent false error reports |
24 |
print '\n At 00 \n' |
1
by ramon diaz-uriarte
initialized after cleaning up |
25 |
while True: |
78
by ramon diaz-uriarte
(trying to) prevent false error reports |
26 |
try: |
27 |
print '\n At 01 \n' |
|
28 |
final_body = self.getBody() |
|
29 |
except: |
|
30 |
time.sleep(5) |
|
31 |
print '\n At 01-except \n' |
|
32 |
final_body = self.getBody() |
|
33 |
||
34 |
print '\n At 001 \n' |
|
1
by ramon diaz-uriarte
initialized after cleaning up |
35 |
if final_body.find(auto_refresh_string) < 0: |
36 |
break
|
|
78
by ramon diaz-uriarte
(trying to) prevent false error reports |
37 |
time.sleep(13) |
1
by ramon diaz-uriarte
initialized after cleaning up |
38 |
refresh_num += 1 |
39 |
run_time = time.time() - start_run |
|
40 |
print '\n Refreshed ' + str(refresh_num) + ' times. Been running for ' + str(round(run_time/60.0, 2)) + ' minutes.\n' |
|
78
by ramon diaz-uriarte
(trying to) prevent false error reports |
41 |
print '\n At 02 \n' |
42 |
||
1
by ramon diaz-uriarte
initialized after cleaning up |
43 |
if run_time > MAX_running_time : |
44 |
self.fail('Run longer than MAX_running_time') |
|
78
by ramon diaz-uriarte
(trying to) prevent false error reports |
45 |
checkdoneUrl = server_url + self.getLastUrl() |
46 |
print '\n checkdoneUrl = ' |
|
47 |
print checkdoneUrl |
|
48 |
||
49 |
try: |
|
50 |
print '\n At 03 \n' |
|
51 |
gg = self.get(checkdoneUrl, |
|
52 |
description="Get /cgi-bin/checkdone.cgi") |
|
53 |
print '\n This is gg \n' |
|
54 |
print str(gg) |
|
55 |
except: |
|
56 |
time.sleep(5) |
|
57 |
print '\n At 03 - except \n' |
|
58 |
gg = self.get(checkdoneUrl, |
|
59 |
description="Get /cgi-bin/checkdone.cgi") |
|
60 |
print '\n This is gg \n' |
|
61 |
print str(gg) |
|
27
by ramon diaz-uriarte
OKs when OK |
62 |
expected = final_body.find(final_output) >= 0 |
63 |
if not expected: |
|
64 |
self.fail('\n ***** (begin of) Unexpected final result!!!! *****\n' + \ |
|
26
by ramon diaz-uriarte
better error messages |
65 |
str(final_body) + \ |
66 |
'\n ***** (end of) Unexpected final result!!!! *****\n') |
|
27
by ramon diaz-uriarte
OKs when OK |
67 |
else: |
68 |
print 'OK' |
|
69 |
||
1
by ramon diaz-uriarte
initialized after cleaning up |
70 |
|
71 |
class Tnasas(FunkLoadTestCase): |
|
72 |
"""XXX
|
|
73 |
||
74 |
This test use a configuration file Genesrf.conf.
|
|
75 |
"""
|
|
76 |
||
77 |
def setUp(self): |
|
78 |
"""Setting up test."""
|
|
79 |
self.logd("setUp") |
|
80 |
self.server_url = 'http://tnasas.bioinfo.cnio.es' |
|
81 |
||
82 |
def test1(self): |
|
83 |
server_url = self.server_url |
|
84 |
self.get(server_url + "/", |
|
85 |
description="Get /") |
|
78
by ramon diaz-uriarte
(trying to) prevent false error reports |
86 |
print '\n Start post \n' |
1
by ramon diaz-uriarte
initialized after cleaning up |
87 |
self.post(server_url + "/cgi-bin/tnasasR.cgi", params=[ |
88 |
['covariate', Upload("xdata2.txt")], |
|
89 |
['class', Upload("Class")], |
|
90 |
['model', 'dlda'], |
|
91 |
['genesel', 'Fratio'], |
|
92 |
['organism', 'None'], |
|
93 |
['idtype', 'None']], |
|
94 |
description="dlda and f ratio") |
|
95 |
final_output = 'Classification algorithm: DLDA; gene selection using F statistic' |
|
96 |
common_part(self, final_output) |
|
97 |
||
98 |
def test2(self): |
|
99 |
server_url = self.server_url |
|
100 |
self.get(server_url + "/", |
|
101 |
description="Get /") |
|
78
by ramon diaz-uriarte
(trying to) prevent false error reports |
102 |
print '\n Start post \n' |
1
by ramon diaz-uriarte
initialized after cleaning up |
103 |
self.post(server_url + "/cgi-bin/tnasasR.cgi", params=[ |
104 |
['covariate', Upload("xdata2.txt")], |
|
105 |
['class', Upload("Class")], |
|
106 |
['model', 'knn'], |
|
107 |
['genesel', 'Wilcoxon'], |
|
108 |
['organism', 'None'], |
|
109 |
['idtype', 'None']], |
|
110 |
description="knn and wilcoxon") |
|
111 |
final_output = 'Classification algorithm: NN; gene selection using Wilcoxon statistic' |
|
112 |
common_part(self, final_output) |
|
113 |
||
114 |
def test3(self): |
|
115 |
server_url = self.server_url |
|
116 |
self.get(server_url + "/", |
|
117 |
description="Get /") |
|
78
by ramon diaz-uriarte
(trying to) prevent false error reports |
118 |
print '\n Start post \n' |
1
by ramon diaz-uriarte
initialized after cleaning up |
119 |
self.post(server_url + "/cgi-bin/tnasasR.cgi", params=[ |
120 |
['covariate', Upload("xdata2.txt")], |
|
121 |
['class', Upload("Class")], |
|
122 |
['model', 'randomforest'], |
|
123 |
['genesel', 'Fratio'], |
|
124 |
['organism', 'None'], |
|
125 |
['idtype', 'None']], |
|
34
by RDU
Tnasas: genes with UG name |
126 |
description="rF and Fratio") |
1
by ramon diaz-uriarte
initialized after cleaning up |
127 |
final_output = 'Classification algorithm: Random forest; gene selection using F statistic' |
128 |
common_part(self, final_output) |
|
129 |
||
130 |
def test4(self): |
|
131 |
server_url = self.server_url |
|
132 |
self.get(server_url + "/", |
|
133 |
description="Get /") |
|
78
by ramon diaz-uriarte
(trying to) prevent false error reports |
134 |
print '\n Start post \n' |
1
by ramon diaz-uriarte
initialized after cleaning up |
135 |
self.post(server_url + "/cgi-bin/tnasasR.cgi", params=[ |
136 |
['covariate', Upload("xdata2.txt")], |
|
137 |
['class', Upload("Class")], |
|
138 |
['model', 'svm'], |
|
139 |
['genesel', 'randomforest'], |
|
140 |
['organism', 'None'], |
|
141 |
['idtype', 'None']], |
|
34
by RDU
Tnasas: genes with UG name |
142 |
description="svm and randomforest gene sel") |
1
by ramon diaz-uriarte
initialized after cleaning up |
143 |
final_output = 'Classification algorithm: SVM (linear kernel); gene selection using Random Forest' |
144 |
common_part(self, final_output) |
|
145 |
||
146 |
def test5(self): |
|
147 |
server_url = self.server_url |
|
148 |
self.get(server_url + "/", |
|
149 |
description="Get /") |
|
78
by ramon diaz-uriarte
(trying to) prevent false error reports |
150 |
print '\n Start post \n' |
1
by ramon diaz-uriarte
initialized after cleaning up |
151 |
self.post(server_url + "/cgi-bin/tnasasR.cgi", params=[ |
152 |
['covariate', Upload("xdata2.txt")], |
|
153 |
['class', Upload("Class")], |
|
154 |
['model', 'PAM'], |
|
155 |
['genesel', 'Fratio'], |
|
156 |
['organism', 'None'], |
|
157 |
['idtype', 'None']], |
|
34
by RDU
Tnasas: genes with UG name |
158 |
description="PAM") |
159 |
final_output = 'Classification algorithm: Shrunken centroids (PAM)' |
|
160 |
common_part(self, final_output) |
|
161 |
||
162 |
||
163 |
||
164 |
def test1_Named(self): |
|
165 |
server_url = self.server_url |
|
166 |
self.get(server_url + "/", |
|
167 |
description="Get /") |
|
78
by ramon diaz-uriarte
(trying to) prevent false error reports |
168 |
print '\n Start post \n' |
34
by RDU
Tnasas: genes with UG name |
169 |
self.post(server_url + "/cgi-bin/tnasasR.cgi", params=[ |
170 |
['covariate', Upload("./with.mm.names/short.covar2.txt")], |
|
171 |
['class', Upload("./with.mm.names/class")], |
|
172 |
['model', 'dlda'], |
|
173 |
['genesel', 'Fratio'], |
|
174 |
['organism', 'Mm'], |
|
175 |
['idtype', 'ug']], |
|
176 |
description="dlda and f ratio, Named") |
|
177 |
final_output = 'Classification algorithm: DLDA; gene selection using F statistic' |
|
178 |
common_part(self, final_output) |
|
179 |
||
180 |
def test2_Named(self): |
|
181 |
server_url = self.server_url |
|
182 |
self.get(server_url + "/", |
|
183 |
description="Get /") |
|
78
by ramon diaz-uriarte
(trying to) prevent false error reports |
184 |
print '\n Start post \n' |
34
by RDU
Tnasas: genes with UG name |
185 |
self.post(server_url + "/cgi-bin/tnasasR.cgi", params=[ |
186 |
['covariate', Upload("./with.mm.names/short.covar2.txt")], |
|
187 |
['class', Upload("./with.mm.names/class")], |
|
188 |
['model', 'knn'], |
|
189 |
['genesel', 'Wilcoxon'], |
|
190 |
['organism', 'Mm'], |
|
191 |
['idtype', 'ug']], |
|
192 |
description="knn and wilcoxon, Named") |
|
193 |
final_output = 'Classification algorithm: NN; gene selection using Wilcoxon statistic' |
|
194 |
common_part(self, final_output) |
|
195 |
||
196 |
def test3_Named(self): |
|
197 |
server_url = self.server_url |
|
198 |
self.get(server_url + "/", |
|
199 |
description="Get /") |
|
78
by ramon diaz-uriarte
(trying to) prevent false error reports |
200 |
print '\n Start post \n' |
34
by RDU
Tnasas: genes with UG name |
201 |
self.post(server_url + "/cgi-bin/tnasasR.cgi", params=[ |
202 |
['covariate', Upload("./with.mm.names/short.covar2.txt")], |
|
203 |
['class', Upload("./with.mm.names/class")], |
|
204 |
['model', 'randomforest'], |
|
205 |
['genesel', 'Fratio'], |
|
206 |
['organism', 'Mm'], |
|
207 |
['idtype', 'ug']], |
|
208 |
description="randomforest and f ratio, named") |
|
209 |
final_output = 'Classification algorithm: Random forest; gene selection using F statistic' |
|
210 |
common_part(self, final_output) |
|
211 |
||
212 |
def test4_Named(self): |
|
213 |
server_url = self.server_url |
|
214 |
self.get(server_url + "/", |
|
215 |
description="Get /") |
|
78
by ramon diaz-uriarte
(trying to) prevent false error reports |
216 |
print '\n Start post \n' |
34
by RDU
Tnasas: genes with UG name |
217 |
self.post(server_url + "/cgi-bin/tnasasR.cgi", params=[ |
218 |
['covariate', Upload("./with.mm.names/short.covar2.txt")], |
|
219 |
['class', Upload("./with.mm.names/class")], |
|
220 |
['model', 'svm'], |
|
221 |
['genesel', 'randomforest'], |
|
222 |
['organism', 'Mm'], |
|
223 |
['idtype', 'ug']], |
|
224 |
description="svm and random forest, Named") |
|
225 |
final_output = 'Classification algorithm: SVM (linear kernel); gene selection using Random Forest' |
|
226 |
common_part(self, final_output) |
|
227 |
||
228 |
def test5_Named(self): |
|
229 |
server_url = self.server_url |
|
230 |
self.get(server_url + "/", |
|
231 |
description="Get /") |
|
78
by ramon diaz-uriarte
(trying to) prevent false error reports |
232 |
print '\n Start post \n' |
34
by RDU
Tnasas: genes with UG name |
233 |
self.post(server_url + "/cgi-bin/tnasasR.cgi", params=[ |
234 |
['covariate', Upload("./with.mm.names/short.covar2.txt")], |
|
235 |
['class', Upload("./with.mm.names/class")], |
|
236 |
['model', 'PAM'], |
|
237 |
['genesel', 'Fratio'], |
|
238 |
['organism', 'Mm'], |
|
239 |
['idtype', 'ug']], |
|
240 |
description="PAM, Named") |
|
241 |
final_output = 'Classification algorithm: Shrunken centroids (PAM)' |
|
242 |
common_part(self, final_output) |
|
243 |
||
1
by ramon diaz-uriarte
initialized after cleaning up |
244 |
|
245 |
||
246 |
def tearDown(self): |
|
247 |
"""Setting up test."""
|
|
248 |
self.logd("tearDown.\n") |
|
249 |
||
250 |
if __name__ in ('main', '__main__'): |
|
251 |
unittest.main() |