Skip to content

Commit dcaa982

Browse files
authored
Unit tests for send_statustext_msg function (#82)
* add unit tests for send_statustext_msg function * Pylint * Black * Flake8 * Modify test_send_messages for oversized msg * Separate valid and invalid messages
1 parent 3369458 commit dcaa982

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

tests/integration/test_send_messages.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def main() -> int:
2323
print("Failed to connect")
2424
return -1
2525

26-
messages = [ # 10 random messages
26+
valid_messages = [ # 10 random valid messages
2727
"System startup",
2828
"Initializing sensors",
2929
"GPS lock acquired",
@@ -36,7 +36,24 @@ def main() -> int:
3636
"Landing sequence initiated",
3737
]
3838

39-
for msg in messages:
39+
invalid_messages = [ # 10 random invalid messages over 50 characters
40+
"Warning: The current altitude exceeds the safe operating limit by a significant margin.",
41+
"Critical error detected in navigation system — immediate manual override recommended.",
42+
"Battery voltage has dropped below the minimum threshold required for safe flight operations.",
43+
"GPS signal lost; attempting to reacquire connection. Flight path stability compromised.",
44+
"Obstacle detected in the projected flight path. Automatic avoidance maneuver failed.",
45+
"Telemetry link unstable. Real-time data transmission may be delayed or incomplete.",
46+
"Motor synchronization fault detected. Recommend performing pre-flight diagnostics.",
47+
"Excessive wind speeds detected at current altitude. Adjusting flight parameters.",
48+
"Payload imbalance identified. Autonomous compensation may affect flight stability.",
49+
"Firmware mismatch between flight controller and companion computer detected.",
50+
]
51+
52+
for msg in valid_messages:
53+
controller.send_statustext_msg(msg, mavutil.mavlink.MAV_SEVERITY_INFO)
54+
time.sleep(DELAY_TIME)
55+
56+
for msg in invalid_messages:
4057
controller.send_statustext_msg(msg, mavutil.mavlink.MAV_SEVERITY_INFO)
4158
time.sleep(DELAY_TIME)
4259

0 commit comments

Comments
 (0)