-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
executable file
·416 lines (411 loc) · 18.3 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
""" Tento jednoduchý testovací skript předpokládá, že je uložen v rootu adresáře a odtud také volán pomocí "python3 malecka1.py", kde malecka1 je můj login na ČVUT. Tento skript nic nekontroluje, předpokládá nově rozbalenou složku semestrální práce a testovací data uložená v adresáři "data". Testy a jejich výstupy budou pro přehlednost uloženy do souboru "output.txt". """
import datetime, subprocess
with open("output.txt", mode='w', encoding='utf-8') as out:
out.write("Výstup provedených testů (" + datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S") + "):\n")
i = 1
u = True
# (1) testy parametru a jejich hodnot, predevsim nevalidni vstupy -> ukazka meznich hodnot
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py", "data/data1", "-t", "%y/%m/%d", "-n", "malecka1.py", "-X", "auto"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 0:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py", "data1/data", "-t", "%y/%m/%d", "-X", "-e", "9"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 2:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py", "data1/data", "-t", "%y/%m/%d", "-e", "9", "-e", "1"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 2:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py", "data/data1", "-t", "%y/%m/%d/%Y"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 2:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py", "data/data1", "-t", "%y/%m/%d/%S"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 1:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py", "data/data1", "-t", "%y/%m/%d", "-X", "min"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 2:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py", "data/data1", "-t", "%y/%m/%d", "-y", "40", "-n", "SKJ", "-x", "40"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 2:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py", "data/data1", "-t", "%y/%m/%d", "-Y", "400", "-y", "40", "-n", "SKJ", "-x", "40/09/09", "-e", "animace"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 2:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py", "data/data1", "-t", "%y/%m/%d", "-Y", "420", "-y", "40", "-n", "SKJ", "-x", "40/09/e9"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 2:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py", "data/data1", "-t", "%y/%m/%d", "-Y", "140", "-y", "40", "-n", "SKJ", "-x", "40/09/09", "-l", "666", "-c", "y=90:x=80/08/10", "-c", "x=70/01/01:x=04/02/29:x=05/02/29"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 2:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py", "data/data1", "-t", "%y/%m/%d", "-f", "neexistuje", "-Y", "240", "-y", "40", "-n", "SKJ", "-x", "40/09/09"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 2:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 2:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py", "data/data1", "-t", "[::]", "-f", "neexistuje", "-Y", "240", "-y", "40", "-n", "SKJ", "-x", "40/09/09"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 2:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py", "data/data1", "-t", "%y/%m/%d", "-Y", "240", "-y", "40", "-n", "SKJ", "-x", "40/09/09", "-X", "40/09/01"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 2:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py", "data/data1", "-t", "%y/%m/%d", "-Y", "240", "-y", "40", "-n", "SKJ", "-g", "grid xtics", "-g", "no parameter for Gnuplot"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 4:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py", "data/data1", "data/zz", "-t", "%y/%m/%d", "-Y", "240", "-y", "40", "-n", "SKJ", "-g", "grid xtics", "-g", "no label"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 1:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i)) # spatna kombinace S F T
args = ["python3", "malecka1.py", "data/data1", "-f", "data/config3", "-F", "24", "-S", "6", "-T", "1"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 4:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i)) # posledni vyskyt v config souboru + spravna kombinace S F T
args = ["python3", "malecka1.py", "data/data1", "-f", "data/config3", "-F", "24", "-S", "1", "-T", "1"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 0:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i)) # chybna direktiva v config souboru
args = ["python3", "malecka1.py", "data/data1", "-f", "data/config2"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 2:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i)) # staci spatna hodnota v config souboru ikdyz preferovana na radce -> error
args = ["python3", "malecka1.py", "data/data1", "-f", "data/config1", "-F", "79"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 2:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
# (2) testy vstupnich souboru (lokalne ulozene), predevsim velke validni vstupy -> dobre ukazky vystupu
out.write("\nTest {0} (vyžaduje připojení k Internetu): ".format(i)) # vic hodnot pro stejne x
args = ["python3", "malecka1.py", "http://goo.gl/sqOCK", "-t", "%H:%M:%S", "-g", "style line 1 lt 4 lc rgb \'red\' lw 3", "-g", "style line 2 lt 5 lc rgb \'yellow\' lw 5"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 1:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0} (vyžaduje připojení k Internetu): ".format(i)) # real sin day
args = ["python3", "malecka1.py", "https://pastebin.com/raw.php?i=4h14Kbt0", "-S", "15", "-T", "30", "-e", "1000", "-t", "[%Y/%m/%d %H:%M:%S]", "-g", "style line 1 lt 4 lc rgb \'red\' lw 3", "-g", "style line 1 lt 10 lc rgb \'yellow\' lw 5", "-X", "[2009/05/12 22:30:00]", "-y", "-2", "-Y", "1.5", "-c", "y=0.8:y=0.4:y=0"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 0:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0} (vyžaduje připojení k Internetu): ".format(i)) # real + int sin day
args = ["python3", "malecka1.py", "https://pastebin.com/raw.php?i=4h14Kbt0", "http://pastebin.com/raw.php?i=vQu8cpJ6", "-S", "40", "-T", "20", "-e", "200", "-t", "[%Y/%m/%d %H:%M:%S]", "-g", "style line 1 lt 4 lc rgb \'red\' lw 3", "-g", "style line 2 lt 5 lc rgb \'blue\' lw 2", "-X", "auto", "-c", "x=[2009/05/12 00:00:00]", "-g", "xlabel \'Python jede\'"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 0:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0} (vyžaduje připojení k Internetu): ".format(i)) # invalid url
args = ["python3", "malecka1.py", "http://pastebin.com/raw.php?i=4h14Kbt0", "http://pastebin.com/raw.php?i=vQu8000000", "-S", "50", "-T", "30", "-e", "250", "-t", "[%Y/%m/%d %H:%M:%S]", "-g", "style line 1 lt 4 lc rgb \'red\' lw 3", "-g", "style line 2 lt 5 lc rgb \'yellow\' lw 5"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 1:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0} (vyžaduje připojení k Internetu): ".format(i)) # week real without anim
args = ["python3", "malecka1.py", "http://pastebin.com/raw.php?i=CJbStLQg", "-F", "55", "-T", "5", "-t", "[%Y/%m/%d %H:%M:%S]", "-g", "style line 1 lt 9 lc rgb \'blue\' lw 2", "-g", "style line 2 lt 7", "-c", "y=-0.6"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 0:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0} (vyžaduje připojení k Internetu): ".format(i)) # week part
args = ["python3", "malecka1.py", "http://pastebin.com/raw.php?i=0H8V8Ykd", "-S", "1", "-F", "28", "-e", "250", "-t", "[%Y/%m/%d %H:%M:%S]", "-g", "grid xtics ytics", "-g", "style line 2 lt 5 lc rgb \'yellow\' lw 5"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 0:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0} (vyžaduje připojení k Internetu): ".format(i)) # 3 soubory
args = ["python3", "malecka1.py", "http://pastebin.com/raw.php?i=xVXCKjef", "http://pastebin.com/raw.php?i=5G00Nsw1", "http://pastebin.com/raw.php?i=f5kCxW4q", "-F", "25", "-e", "100", "-t", "[%Y/%m/%d %H:%M:%S]", "-g", "ylabel \'Values\'"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 0:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py", "data/1501rows.data", "-F", "25", "-e", "100", "-t", "[%Y/%m/%d %H:%M:%S]", "-y", "-10.0", "-Y", "auto"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 0:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py", "data/emptyFile", "-y", "auto"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 1:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py", "data/incorrectYValues.data", "-F", "250", "-e", "10000", "-t", "[%Y/%m/%d %H:%M:%S]"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 1:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py", "data/specialFormat.data", "-f", "data/config4"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 0:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py", "data/bad_order_sdi_1_4.data", "data/bad_order_sdi_2_1.data", "data/bad_order_sdi_3_2.data", "data/bad_order_sdi_4_3.data", "-f", "data/config5", "-t", "[%Y/%m/%d %H:%M:%S]"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 0:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
out.write("\nTest {0}: ".format(i))
args = ["python3", "malecka1.py", "data/big.data", "-f", "data/config6"]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = p.communicate()
if p.returncode == 0:
out.write("OK\n")
else:
u = False
out.write("failed\n")
out.write(" ".join(p.args) + "\n")
out.write(error.decode('utf-8'))
i+=1
# konec testu
if u:
out.write("\nVšechny testy probehly úspěšně!")
else:
out.write("\nNěkteré testy se nezdařily.")