-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunit_test.py
85 lines (72 loc) · 2.95 KB
/
unit_test.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
import unittest
from lsl_emulator import start_lsl
from serial_emulator import start_serial
import biostream
from multiprocessing import Process
from time import sleep
'''
@author Maria A Marrero Ortiz
'''
class TestBioStream(unittest.TestCase):
""" *** Run Data Collection Unit Tests...
tests should start with "test_" in order to be considered """
""" *** tests for LSL only *** """
def test_lslnotconnected(self):
biostream_process = Process(target= biostream.main_test)
biostream_process.start()
biostream_process.join()
self.assertEqual(biostream_process.exitcode, 1)
def test_lsldisconnection(self):
lsl_emulator_process = Process(target=start_lsl)
biostream_process = Process(target= biostream.main_test)
lsl_emulator_process.start()
biostream_process.start()
sleep(1)
lsl_emulator_process.terminate()
biostream_process.join()
self.assertEqual(biostream_process.exitcode, 3)
#def test_numberofsamples(self):
""" *** tests for LSL and Knee Encoder (serial device) *** """
def test_lslnotconnected_2(self):
serial_emulator_process = Process(target= start_serial)
biostream_process = Process(target= biostream.main_test)
serial_emulator_process.start()
biostream_process.start()
biostream_process.join()
self.assertEqual(biostream_process.exitcode, 1)
serial_emulator_process.terminate()
def test_serialnotconnected(self):
lsl_emulator_process = Process(target= start_lsl)
lsl_emulator_process.start()
biostream_process = Process(target= biostream.main_test)
biostream_process.start()
biostream_process.join()
self.assertEqual(biostream_process.exitcode, 2)
lsl_emulator_process.terminate()
def test_lsldisconnection_2(self):
lsl_emulator_process = Process(target=start_lsl)
serial_emulator_process = Process(target= start_serial)
biostream_process = Process(target= biostream.main_test)
lsl_emulator_process.start()
serial_emulator_process.start()
biostream_process.start()
sleep(1)
lsl_emulator_process.terminate()
biostream_process.join()
self.assertEqual(biostream_process.exitcode, 3)
serial_emulator_process.terminate()
def test_serialdisconnection(self):
lsl_emulator_process = Process(target=start_lsl)
serial_emulator_process = Process(target= start_serial)
biostream_process = Process(target= biostream.main_test)
lsl_emulator_process.start()
serial_emulator_process.start()
biostream_process.start()
sleep(1)
serial_emulator_process.terminate()
biostream_process.join()
self.assertEqual(biostream_process.exitcode, 3)
lsl_emulator_process.terminate()
#def test_numberofsamples_2(self):
if __name__ == '__main__':
unittest.main()