From 6a345f968cc3e1130912f11bd5ce310d8264753d Mon Sep 17 00:00:00 2001 From: Matthew-Dobson Date: Fri, 14 Nov 2025 14:17:31 +0000 Subject: [PATCH 1/3] fixed spelling of receive and received through a global search of the entire backend --- .../app/controllers/flightModesController.py | 4 ++-- radio/tests/helpers.py | 4 ++-- radio/tests/test_comPorts.py | 24 +++++++++---------- radio/tests/test_gripper.py | 24 +++++++++---------- radio/tests/test_motors.py | 8 +++---- radio/tests/test_states.py | 6 ++--- 6 files changed, 35 insertions(+), 35 deletions(-) diff --git a/radio/app/controllers/flightModesController.py b/radio/app/controllers/flightModesController.py index f2b6d05e5..3cc77aec4 100644 --- a/radio/app/controllers/flightModesController.py +++ b/radio/app/controllers/flightModesController.py @@ -137,7 +137,7 @@ def setCurrentFlightMode(self, flightMode: int) -> Response: Args: flightmode (int): The numeric value for the current flight mode setting Returns: - A message to show if the drone recieved the message and succesfully set the new mode + A message to show if the drone received the message and succesfully set the new mode """ if not self.drone.reserve_message_type("COMMAND_ACK", self.controller_id): return { @@ -185,7 +185,7 @@ def setGuidedMode(self) -> Response: """ Set the drone's flight mode to Guided mode. Returns: - A message to show if the drone recieved the message and succesfully set the new mode + A message to show if the drone received the message and succesfully set the new mode """ mode = mavutil.mavlink.COPTER_MODE_GUIDED diff --git a/radio/tests/helpers.py b/radio/tests/helpers.py index adba63a65..b15a228ae 100644 --- a/radio/tests/helpers.py +++ b/radio/tests/helpers.py @@ -102,7 +102,7 @@ def __exit__(self, type, value, traceback) -> None: droneStatus.drone.aircraft_type = self.old_aircraftType -def send_and_recieve(endpoint: str, args: Optional[Union[dict, str]] = None) -> dict: +def send_and_received(endpoint: str, args: Optional[Union[dict, str]] = None) -> dict: """Sends a request to the socketio test client and returns the response Parameters @@ -115,7 +115,7 @@ def send_and_recieve(endpoint: str, args: Optional[Union[dict, str]] = None) -> Returns ------- dict - The data recieved from the client + The data received from the client """ ( socketio_client.emit(endpoint, args) diff --git a/radio/tests/test_comPorts.py b/radio/tests/test_comPorts.py index 3f27f0243..5e7c320e8 100644 --- a/radio/tests/test_comPorts.py +++ b/radio/tests/test_comPorts.py @@ -7,7 +7,7 @@ from . import socketio_client from .conftest import setupDrone -from .helpers import send_and_recieve +from .helpers import send_and_receive VALID_DRONE_PORT: str @@ -45,7 +45,7 @@ def get_comport_name(port): def test_getComPort() -> None: # TODO: we should automate different OS environments for our unit tests maybe? assert ( - send_and_recieve("get_com_ports") + send_and_receive("get_com_ports") == [ f"{get_comport_name(port)}: {port.description}" for port in list_ports.comports() @@ -56,28 +56,28 @@ def test_getComPort() -> None: def test_connectToDrone_badType() -> None: # Failure on bad connection type - assert send_and_recieve("connect_to_drone", {}) == { + assert send_and_receive("connect_to_drone", {}) == { "message": "Connection type not specified." } - assert send_and_recieve("connect_to_drone", {"connectionType": "testtype"}) == { + assert send_and_receive("connect_to_drone", {"connectionType": "testtype"}) == { "message": "Connection type not specified." } def test_connectToDrone_badPort() -> None: # Failure on no port specified - assert send_and_recieve("connect_to_drone", {"connectionType": "serial"}) == { + assert send_and_receive("connect_to_drone", {"connectionType": "serial"}) == { "message": "COM port not specified." } - assert send_and_recieve("connect_to_drone", {"connectionType": "network"}) == { + assert send_and_receive("connect_to_drone", {"connectionType": "network"}) == { "message": "Connection address not specified." } # Failure on bad port specified - assert send_and_recieve( + assert send_and_receive( "connect_to_drone", {"connectionType": "serial", "port": "testport"} ) == {"message": "COM port not found."} - assert send_and_recieve( + assert send_and_receive( "connect_to_drone", {"connectionType": "serial", "port": "COM10:5761"} ) == {"message": "COM port not found."} @@ -139,13 +139,13 @@ def test_connectToDrone_badBaud() -> None: ) # Failure on invalid baud rate value - assert send_and_recieve( + assert send_and_receive( "connect_to_drone", {"connectionType": connectionType, "port": VALID_DRONE_PORT, "baud": -1}, ) == { "message": f"{-1} is an invalid baudrate. Valid baud rates are {Drone.getValidBaudrates()}" } - assert send_and_recieve( + assert send_and_receive( "connect_to_drone", {"connectionType": connectionType, "port": VALID_DRONE_PORT, "baud": 110}, ) == { @@ -153,11 +153,11 @@ def test_connectToDrone_badBaud() -> None: } # Failure on invalid baud rate types - assert send_and_recieve( + assert send_and_receive( "connect_to_drone", {"connectionType": connectionType, "port": VALID_DRONE_PORT, "baud": 9600.0}, ) == {"message": "Expected integer value for baud, received float."} - assert send_and_recieve( + assert send_and_receive( "connect_to_drone", {"connectionType": connectionType, "port": VALID_DRONE_PORT, "baud": "9600"}, ) == {"message": "Expected integer value for baud, received str."} diff --git a/radio/tests/test_gripper.py b/radio/tests/test_gripper.py index 649071631..e9fe03d98 100644 --- a/radio/tests/test_gripper.py +++ b/radio/tests/test_gripper.py @@ -5,7 +5,7 @@ from pymavlink import mavutil from . import falcon_test -from .helpers import FakeTCP, NoDrone, send_and_recieve +from .helpers import FakeTCP, NoDrone, send_and_receive @pytest.fixture(scope="module", autouse=True) @@ -32,56 +32,56 @@ def run_once_after_all_tests(): def test_gripperEnabled(socketio_client: SocketIOTestClient, droneStatus): # Failure on wrong drone state droneStatus.state = "params" - assert send_and_recieve("get_gripper_enabled") == { + assert send_and_receive("get_gripper_enabled") == { "message": "You must be on the config screen to access the gripper." } # Failure with no drone connected droneStatus.state = "config" with NoDrone(): - assert send_and_recieve("get_gripper_enabled") == { + assert send_and_receive("get_gripper_enabled") == { "message": "You must be connected to the drone to access the gripper." } # Correct result on config page - assert send_and_recieve("get_gripper_enabled") is True + assert send_and_receive("get_gripper_enabled") is True @falcon_test(pass_drone_status=True) def test_setGripper(socketio_client: SocketIOTestClient, droneStatus): # Failure on wrong drone state droneStatus.state = "params" - assert send_and_recieve("set_gripper", "release") == { + assert send_and_receive("set_gripper", "release") == { "message": "You must be on the config screen to access the gripper." } # Failure with no drone connected droneStatus.state = "config" with NoDrone(): - assert send_and_recieve("set_gripper", "release") == { + assert send_and_receive("set_gripper", "release") == { "message": "You must be connected to the drone to access the gripper." } # Failure on incorrect gripper value - assert send_and_recieve("set_gripper", "testgrippervalue") == { + assert send_and_receive("set_gripper", "testgrippervalue") == { "message": 'Gripper action must be either "release" or "grab"' } # Success on release - assert send_and_recieve("set_gripper", "release") == { + assert send_and_receive("set_gripper", "release") == { "success": True, "message": "Setting gripper to release", } # Success on grab - assert send_and_recieve("set_gripper", "grab") == { + assert send_and_receive("set_gripper", "grab") == { "success": True, "message": "Setting gripper to grab", } # Serial exception handled correctly with FakeTCP(): - assert send_and_recieve("set_gripper", "grab") == { + assert send_and_receive("set_gripper", "grab") == { "success": False, "message": "Setting gripper failed, serial exception", } @@ -95,8 +95,8 @@ def test_gripperDisabled(socketio_client: SocketIOTestClient, droneStatus) -> No # Allow time for gripper to be updated time.sleep(0.5) - assert send_and_recieve("get_gripper_enabled") is False - assert send_and_recieve("set_gripper", "release") == { + assert send_and_receive("get_gripper_enabled") is False + assert send_and_receive("set_gripper", "release") == { "success": False, "message": "Gripper is not enabled", } diff --git a/radio/tests/test_motors.py b/radio/tests/test_motors.py index 7bbe40fe7..b232a006f 100644 --- a/radio/tests/test_motors.py +++ b/radio/tests/test_motors.py @@ -13,11 +13,11 @@ def assert_motorResult( err: Optional[str] = None, ) -> None: """ - Takes the data recieved from the socketio test client and asserts that it matches the given + Takes the data received from the socketio test client and asserts that it matches the given expected values Args: - data (dict): The data recieved using `client.get_recieved()` + data (dict): The data received using `client.get_received()` success (bool): Whether the request should have been successful or not motor (str, optional): Which motor the request should have tested, default `None` err (str, optional): What the error message should have been, default `None` @@ -42,7 +42,7 @@ def send_testOneMotor( duration (int): The duration of the test Returns: - dict: The data recieved from the client using `.get_recieved()` + dict: The data received from the client using `.get_received()` """ client.emit( "test_one_motor", @@ -66,7 +66,7 @@ def send_testMotors( duration (int): The duration of the test Returns: - dict: The data recieved from the client using `.get_recieved()` + dict: The data received from the client using `.get_received()` """ client.emit( "test_all_motors" if test_all else "test_motor_sequence", diff --git a/radio/tests/test_states.py b/radio/tests/test_states.py index c7e7feba3..4653159da 100644 --- a/radio/tests/test_states.py +++ b/radio/tests/test_states.py @@ -1,19 +1,19 @@ from flask_socketio import SocketIOTestClient from . import falcon_test -from .helpers import NoDrone, send_and_recieve +from .helpers import NoDrone, send_and_receive @falcon_test(pass_drone_status=True) def test_setState(socketio_client: SocketIOTestClient, droneStatus) -> None: # Failure on no drone connection with NoDrone(): - assert send_and_recieve("set_state", "dashboard") == { + assert send_and_receive("set_state", "dashboard") == { "message": "Must be connected to the drone to set the drone state." } # Failure on no state sent - assert send_and_recieve("set_state", {}) == { + assert send_and_receive("set_state", {}) == { "message": "Request to endpoint set_state missing value for parameter: state." } From 85f4099a73b19200534c11939ff9304e55bd990e Mon Sep 17 00:00:00 2001 From: Matthew-Dobson Date: Fri, 14 Nov 2025 14:29:52 +0000 Subject: [PATCH 2/3] linters + fix spelling of "successfully" --- .../app/controllers/flightModesController.py | 4 +-- radio/tests/test_mission.py | 33 ++++++++++++------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/radio/app/controllers/flightModesController.py b/radio/app/controllers/flightModesController.py index 3cc77aec4..5c11d5367 100644 --- a/radio/app/controllers/flightModesController.py +++ b/radio/app/controllers/flightModesController.py @@ -137,7 +137,7 @@ def setCurrentFlightMode(self, flightMode: int) -> Response: Args: flightmode (int): The numeric value for the current flight mode setting Returns: - A message to show if the drone received the message and succesfully set the new mode + A message to show if the drone received the message and successfully set the new mode """ if not self.drone.reserve_message_type("COMMAND_ACK", self.controller_id): return { @@ -185,7 +185,7 @@ def setGuidedMode(self) -> Response: """ Set the drone's flight mode to Guided mode. Returns: - A message to show if the drone received the message and succesfully set the new mode + A message to show if the drone received the message and successfully set the new mode """ mode = mavutil.mavlink.COPTER_MODE_GUIDED diff --git a/radio/tests/test_mission.py b/radio/tests/test_mission.py index d0a75c44f..430a7854c 100644 --- a/radio/tests/test_mission.py +++ b/radio/tests/test_mission.py @@ -548,10 +548,13 @@ def test_exportMissionToFile_missionExportSuccess( "message": f"Waypoint file saved 8 points successfully to {export_file_path}", } assert os.path.exists(export_file_path) - with open(export_file_path, "r") as f, open( - os.path.join(MISSION_FILES_PATH, "exported_mission_check.txt"), - "r", - ) as f_expected: + with ( + open(export_file_path, "r") as f, + open( + os.path.join(MISSION_FILES_PATH, "exported_mission_check.txt"), + "r", + ) as f_expected, + ): assert f.read() == f_expected.read() @@ -581,10 +584,13 @@ def test_exportMissionToFile_fenceExportSuccess( "message": f"Waypoint file saved 13 points successfully to {export_file_path}", } assert os.path.exists(export_file_path) - with open(export_file_path, "r") as f, open( - os.path.join(MISSION_FILES_PATH, "exported_fence_check.txt"), - "r", - ) as f_expected: + with ( + open(export_file_path, "r") as f, + open( + os.path.join(MISSION_FILES_PATH, "exported_fence_check.txt"), + "r", + ) as f_expected, + ): assert f.read() == f_expected.read() @@ -614,10 +620,13 @@ def test_exportMissionToFile_rallyExportSuccess( "message": f"Waypoint file saved 2 points successfully to {export_file_path}", } assert os.path.exists(export_file_path) - with open(export_file_path, "r") as f, open( - os.path.join(MISSION_FILES_PATH, "exported_rally_check.txt"), - "r", - ) as f_expected: + with ( + open(export_file_path, "r") as f, + open( + os.path.join(MISSION_FILES_PATH, "exported_rally_check.txt"), + "r", + ) as f_expected, + ): assert f.read() == f_expected.read() From c374a5e5cbddafaa4bd29c5e67b4ff4d0e3949b7 Mon Sep 17 00:00:00 2001 From: Matthew-Dobson Date: Fri, 14 Nov 2025 14:58:37 +0000 Subject: [PATCH 3/3] fix: accidentally switched received to receive --- radio/tests/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/tests/helpers.py b/radio/tests/helpers.py index b15a228ae..173eaf081 100644 --- a/radio/tests/helpers.py +++ b/radio/tests/helpers.py @@ -102,7 +102,7 @@ def __exit__(self, type, value, traceback) -> None: droneStatus.drone.aircraft_type = self.old_aircraftType -def send_and_received(endpoint: str, args: Optional[Union[dict, str]] = None) -> dict: +def send_and_receive(endpoint: str, args: Optional[Union[dict, str]] = None) -> dict: """Sends a request to the socketio test client and returns the response Parameters