def test_motor_mutability() -> None: """ Test the mutability of Motors. Ensures that Motor objects cannot be lost. """ mb = MotorBoard("SERIAL0", MockMotorBoardBackend()) with pytest.raises(TypeError): mb.motors[1] = 1 # type: ignore
def test_motor_board_make_safe() -> None: """Test the make_safe method of the motor board.""" mb = MotorBoard("SERIAL0", MockMotorBoardBackend()) for m in mb.motors: m.power = 1 mb.make_safe() for m in mb.motors: assert m.power == MotorSpecialState.BRAKE
def test_motor_board_make_safe_option() -> None: """Test the default make_safe method of the motor board.""" TEST_SAFE_STATES: List[MotorState] = [ MotorSpecialState.BRAKE, MotorSpecialState.COAST, 0, 0.1, ] for safe_state in TEST_SAFE_STATES: mb = MotorBoard("SERIAL0", MockMotorBoardBackend(), safe_state=safe_state) for m in mb.motors: m.power = 1 mb.make_safe() for m in mb.motors: assert m.power == safe_state
def test_motor_board_motors() -> None: """Test the motor_outputs on the motor board.""" mb = MotorBoard("SERIAL0", MockMotorBoardBackend()) for m in mb.motors: assert type(m) is Motor
def test_motor_board_serial() -> None: """Test the serial attribute of the motor board.""" mb = MotorBoard("SERIAL0", MockMotorBoardBackend()) assert mb.serial == "SERIAL0"
def test_motor_board_name() -> None: """Test the name attribute of the motor board.""" mb = MotorBoard("SERIAL0", MockMotorBoardBackend()) assert mb.name == "Student Robotics v4 Motor Board"
def test_motor_board_firmware_version() -> None: """Test the firmware version on the motor board.""" mb = MotorBoard("SERIAL0", MockMotorBoardBackend()) assert mb.firmware_version is None
def test_motor_board_instantiation() -> None: """Test that we can instantiate a Motor Board.""" MotorBoard("SERIAL0", MockMotorBoardBackend())
def test_motor_board_supported_components() -> None: """Test the supported components on the motor board.""" assert MotorBoard.supported_components() == {Motor}