-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_master_process.py
65 lines (44 loc) · 1.75 KB
/
test_master_process.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
"""
Unit tests for master process
"""
from master_process import MasterProcess
from pid import PIDControl
"""
Test Scenario: Application starts Odisseus MasterProcess
Expected Output: All Odisseus processes should be started
"""
def test_create_processes(odisseus_config_obj):
error_msg = "No Erro in test"+test_create_processes.__name__
master = MasterProcess(odisseus_configuration=odisseus_config_obj)
pid_control = PIDControl(Kp = odisseus_config_obj.PROPULSION_PID_Kp, Ki=odisseus_config_obj.PROPULSION_PID_Ki, Kd=odisseus_config_obj.PROPULSION_PID_Kd)
kwargs = dict()
kwargs[odisseus_config_obj.PROPULSION_CONTROLLER_NAME] = pid_control
master.create_processes(**kwargs)
names = master.get_processes_names()
count = 0
if odisseus_config_obj.ENABLE_IR_SENSOR:
count += 1
if odisseus_config_obj.ENABLE_CAMERA:
count += 1
if odisseus_config_obj.ENABLE_MOTORS:
count +=1
if odisseus_config_obj.ENABLE_ULTRASOUND_SENSOR:
count += 1
if odisseus_config_obj.ENABLE_WEB_SERVER:
count += 1
master.terminate_all_processes()
if count != len(names):
error_msg = "ERROR in {0}: Not all processes were started. Should be {1} but started only {2} ".format(test_create_processes.__name__, count, len(names))
return error_msg
def test(odisseus_configuration):
errors = []
error_msg = test_create_processes(odisseus_config_obj=odisseus_configuration)
if error_msg[0:5] == "ERROR":
errors.append(error_msg)
if len(errors) != 0:
print("ERRORS Occurred")
for error in errors:
print(error)
if __name__ == '__main__':
from odisseus_config import odisseus_config_obj
test(odisseus_configuration=odisseus_config_obj)