17
17
18
18
19
19
def test_add_connection () -> None :
20
- fc = FlightController (reboot_time = 7 )
20
+ fc = FlightController (reboot_time = 7 , baudrate = 115200 )
21
21
assert fc .add_connection ("test_connection" ) is True
22
22
assert fc .add_connection ("test_connection" ) is False
23
23
assert fc .add_connection ("" ) is False
24
24
25
25
26
26
def test_discover_connections () -> None :
27
- fc = FlightController (reboot_time = 7 )
27
+ fc = FlightController (reboot_time = 7 , baudrate = 115200 )
28
28
fc .discover_connections ()
29
29
assert len (fc .get_connection_tuples ()) > 0
30
30
31
31
32
32
def test_connect () -> None :
33
- fc = FlightController (reboot_time = 7 )
33
+ fc = FlightController (reboot_time = 7 , baudrate = 115200 )
34
34
result = fc .connect (device = "test" )
35
35
assert result == ""
36
36
37
37
38
38
def test_disconnect () -> None :
39
- fc = FlightController (reboot_time = 7 )
39
+ fc = FlightController (reboot_time = 7 , baudrate = 115200 )
40
40
fc .connect (device = "test" )
41
41
fc .disconnect ()
42
42
assert fc .master is None
@@ -48,7 +48,7 @@ def test_disconnect() -> None:
48
48
side_effect = lambda x : {"param1" : Par (1 , x ), "param2" : Par (2 , x )},
49
49
)
50
50
def test_download_params (mock_load_param_file_into_dict , mock_file ) -> None :
51
- fc = FlightController (reboot_time = 7 )
51
+ fc = FlightController (reboot_time = 7 , baudrate = 115200 )
52
52
fc .connect (device = "test" )
53
53
with patch ("ardupilot_methodic_configurator.backend_flightcontroller.open" , mock_file ):
54
54
params , _ = fc .download_params ()
@@ -63,7 +63,7 @@ def test_download_params(mock_load_param_file_into_dict, mock_file) -> None:
63
63
side_effect = lambda x : {"param1" : Par (1 , x ), "param2" : Par (2 , x )},
64
64
)
65
65
def test_set_param (mock_load_param_file_into_dict , mock_file ) -> None :
66
- fc = FlightController (reboot_time = 7 )
66
+ fc = FlightController (reboot_time = 7 , baudrate = 115200 )
67
67
fc .connect (device = "test" )
68
68
fc .set_param ("TEST_PARAM" , 1.0 )
69
69
with patch ("ardupilot_methodic_configurator.backend_flightcontroller.open" , mock_file ):
@@ -73,22 +73,22 @@ def test_set_param(mock_load_param_file_into_dict, mock_file) -> None:
73
73
74
74
75
75
def test_reset_and_reconnect () -> None :
76
- fc = FlightController (reboot_time = 7 )
76
+ fc = FlightController (reboot_time = 7 , baudrate = 115200 )
77
77
fc .connect (device = "test" )
78
78
result = fc .reset_and_reconnect ()
79
79
assert result == ""
80
80
81
81
82
82
def test_upload_file () -> None :
83
- fc = FlightController (reboot_time = 7 )
83
+ fc = FlightController (reboot_time = 7 , baudrate = 115200 )
84
84
fc .connect (device = "test" )
85
85
result = fc .upload_file ("local.txt" , "remote.txt" )
86
86
# Assuming the mock environment always returns False for upload_file
87
87
assert result is False
88
88
89
89
90
90
def test_get_connection_tuples () -> None :
91
- fc = FlightController (reboot_time = 7 )
91
+ fc = FlightController (reboot_time = 7 , baudrate = 115200 )
92
92
fc .add_connection ("test_connection" )
93
93
connections = fc .get_connection_tuples ()
94
94
assert ("test_connection" , "test_connection" ) in connections
@@ -100,7 +100,7 @@ def test_get_connection_tuples() -> None:
100
100
side_effect = lambda x : {"param1" : Par (1 , x ), "param2" : Par (2 , x )},
101
101
)
102
102
def test_set_param_and_verify (mock_load_param_file_into_dict , mock_file ) -> None :
103
- fc = FlightController (reboot_time = 7 )
103
+ fc = FlightController (reboot_time = 7 , baudrate = 115200 )
104
104
fc .connect (device = "test" )
105
105
fc .set_param ("TEST_PARAM" , 1.0 )
106
106
with patch ("ardupilot_methodic_configurator.backend_flightcontroller.open" , mock_file ):
@@ -111,15 +111,15 @@ def test_set_param_and_verify(mock_load_param_file_into_dict, mock_file) -> None
111
111
112
112
113
113
def test_download_params_via_mavftp () -> None :
114
- fc = FlightController (reboot_time = 7 )
114
+ fc = FlightController (reboot_time = 7 , baudrate = 115200 )
115
115
fc .connect (device = "test" )
116
116
params , default_params = fc .download_params_via_mavftp ()
117
117
assert isinstance (params , dict )
118
118
assert isinstance (default_params , dict )
119
119
120
120
121
121
def test_auto_detect_serial () -> None :
122
- fc = FlightController (reboot_time = 7 )
122
+ fc = FlightController (reboot_time = 7 , baudrate = 115200 )
123
123
serial_ports = fc ._FlightController__auto_detect_serial () # pylint: disable=protected-access
124
124
assert isinstance (serial_ports , list )
125
125
@@ -136,34 +136,34 @@ def test_list_network_ports() -> None:
136
136
137
137
138
138
def test_request_banner () -> None :
139
- fc = FlightController (reboot_time = 7 )
139
+ fc = FlightController (reboot_time = 7 , baudrate = 115200 )
140
140
fc .connect (device = "test" )
141
141
fc ._FlightController__request_banner () # pylint: disable=protected-access
142
142
# Since we cannot verify in the mock environment, we will just ensure no exceptions are raised
143
143
144
144
145
145
def test_receive_banner_text () -> None :
146
- fc = FlightController (reboot_time = 7 )
146
+ fc = FlightController (reboot_time = 7 , baudrate = 115200 )
147
147
fc .connect (device = "test" )
148
148
banner_text = fc ._FlightController__receive_banner_text () # pylint: disable=protected-access
149
149
assert isinstance (banner_text , list )
150
150
151
151
152
152
def test_request_message () -> None :
153
- fc = FlightController (reboot_time = 7 )
153
+ fc = FlightController (reboot_time = 7 , baudrate = 115200 )
154
154
fc .connect (device = "test" )
155
155
fc ._FlightController__request_message (1 ) # pylint: disable=protected-access
156
156
# Since we cannot verify in the mock environment, we will just ensure no exceptions are raised
157
157
158
158
159
159
def test_create_connection_with_retry () -> None :
160
- fc = FlightController (reboot_time = 7 )
160
+ fc = FlightController (reboot_time = 7 , baudrate = 115200 )
161
161
result = fc ._FlightController__create_connection_with_retry (progress_callback = None , retries = 1 , timeout = 1 ) # pylint: disable=protected-access
162
162
assert result == ""
163
163
164
164
165
165
def test_process_autopilot_version () -> None :
166
- fc = FlightController (reboot_time = 7 )
166
+ fc = FlightController (reboot_time = 7 , baudrate = 115200 )
167
167
fc .connect (device = "test" )
168
168
banner_msgs = ["ChibiOS: 123" , "ArduPilot" ]
169
169
result = fc ._FlightController__process_autopilot_version (None , banner_msgs ) # pylint: disable=protected-access
0 commit comments